From 4049b9d10a92274e673170febd6edb2db1c440c5 Mon Sep 17 00:00:00 2001 From: Teon Banek Date: Fri, 28 Feb 2020 09:36:29 +0100 Subject: [PATCH] Add mgp_path_copy to C API Reviewers: ipaljak Reviewed By: ipaljak Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2694 --- include/mg_procedure.h | 6 ++++++ src/query/procedure/mg_procedure_impl.cpp | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/include/mg_procedure.h b/include/mg_procedure.h index c3908d56a..57120503a 100644 --- a/include/mg_procedure.h +++ b/include/mg_procedure.h @@ -344,6 +344,12 @@ const struct mgp_map_item *mgp_map_items_iterator_next( struct mgp_path *mgp_path_make_with_start(const struct mgp_vertex *vertex, struct mgp_memory *memory); +/// Copy a mgp_path. +/// Returned pointer must be freed with mgp_path_destroy. +/// NULL is returned if unable to allocate a mgp_path. +struct mgp_path *mgp_path_copy(const struct mgp_path *path, + struct mgp_memory *memory); + /// Free the memory used by the given mgp_path and contained vertices and edges. void mgp_path_destroy(struct mgp_path *path); diff --git a/src/query/procedure/mg_procedure_impl.cpp b/src/query/procedure/mg_procedure_impl.cpp index 67736e1fa..e6b96be6e 100644 --- a/src/query/procedure/mg_procedure_impl.cpp +++ b/src/query/procedure/mg_procedure_impl.cpp @@ -729,6 +729,10 @@ mgp_path *mgp_path_make_with_start(const mgp_vertex *vertex, return path; } +mgp_path *mgp_path_copy(const mgp_path *path, mgp_memory *memory) { + return new_mgp_object(memory, *path); +} + void mgp_path_destroy(mgp_path *path) { delete_mgp_object(path); } int mgp_path_expand(mgp_path *path, const mgp_edge *edge) {