@@ -44,7 +44,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
4444#include " withPoints/withPoints.hpp"
4545#include " c_types/mst_rt.h"
4646#include " cpp_common/combinations.hpp"
47- #include " cpp_common/alloc .hpp"
47+ #include " cpp_common/to_postgres .hpp"
4848
4949
5050void
@@ -66,7 +66,6 @@ pgr_do_withPointsDD(
6666 char ** notice_msg,
6767 char ** err_msg) {
6868 using pgrouting::Path;
69- using pgrouting::pgr_alloc;
7069 using pgrouting::to_pg_msg;
7170 using pgrouting::pgr_free;
7271 using pgrouting::pgget::get_intSet;
@@ -87,6 +86,8 @@ pgr_do_withPointsDD(
8786 pgassert (!(*return_tuples));
8887 pgassert (*return_count == 0 );
8988
89+ using pgrouting::to_postgres::get_tuples;
90+
9091 auto roots = get_intSet (starts);
9192
9293 hint = points_sql;
@@ -141,21 +142,14 @@ pgr_do_withPointsDD(
141142 }
142143
143144
144- auto count (count_tuples (paths));
145-
145+ *return_count = get_tuples (paths, *return_tuples);
146146
147- if (count == 0 ) {
148- (*return_tuples) = NULL ;
149- (*return_count) = 0 ;
150- notice << " No paths found" ;
151- *log_msg = to_pg_msg (notice);
147+ if (*return_count == 0 ) {
148+ *log_msg = to_pg_msg (" No paths found" );
152149 return ;
153150 }
154151
155- (*return_tuples) = pgr_alloc (count, (*return_tuples));
156- (*return_count) = (collapse_paths (return_tuples, paths));
157-
158- for (size_t i = 0 ; i < count; i++) {
152+ for (size_t i = 0 ; i < *return_count; i++) {
159153 auto row = (*return_tuples)[i];
160154 /* given the depth assign the correct depth */
161155 int64_t depth = -1 ;
@@ -169,11 +163,11 @@ pgr_do_withPointsDD(
169163 }
170164
171165 /* sort to get depths in order*/
172- std::sort ((*return_tuples), (*return_tuples) + count ,
166+ std::sort ((*return_tuples), (*return_tuples) + *return_count ,
173167 [](const MST_rt &l, const MST_rt &r) {return l.agg_cost < r.agg_cost ;});
174- std::stable_sort ((*return_tuples), (*return_tuples) + count ,
168+ std::stable_sort ((*return_tuples), (*return_tuples) + *return_count ,
175169 [](const MST_rt &l, const MST_rt &r) {return l.depth < r.depth ;});
176- std::stable_sort ((*return_tuples), (*return_tuples) + count ,
170+ std::stable_sort ((*return_tuples), (*return_tuples) + *return_count ,
177171 [](const MST_rt &l, const MST_rt &r) {return l.from_v < r.from_v ;});
178172
179173 *log_msg = to_pg_msg (log);
0 commit comments