From 1233bcde37e25a41f2230a64aded9bd5813098cd Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 8 Apr 2024 10:34:58 +0200 Subject: [PATCH] libstore-c: Add nix_store_path_clone --- src/libstore-c/nix_api_store.cc | 5 +++++ src/libstore-c/nix_api_store.h | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/libstore-c/nix_api_store.cc b/src/libstore-c/nix_api_store.cc index d80ba332e..d044ba14f 100644 --- a/src/libstore-c/nix_api_store.cc +++ b/src/libstore-c/nix_api_store.cc @@ -132,3 +132,8 @@ void nix_store_path_free(StorePath * sp) { delete sp; } + +StorePath * nix_store_path_clone(const StorePath * p) +{ + return new StorePath{p->path}; +} diff --git a/src/libstore-c/nix_api_store.h b/src/libstore-c/nix_api_store.h index 577b70151..ab86a81df 100644 --- a/src/libstore-c/nix_api_store.h +++ b/src/libstore-c/nix_api_store.h @@ -90,6 +90,14 @@ nix_err nix_store_get_uri(nix_c_context * context, Store * store, void * callbac */ StorePath * nix_store_parse_path(nix_c_context * context, Store * store, const char * path); +/** + * @brief Copy a StorePath + * + * @param[in] p the path to copy + * @return a new StorePath + */ +StorePath * nix_store_path_clone(const StorePath * p); + /** @brief Deallocate a StorePath * * Does not fail.