diff --git a/libpkgconf/libpkgconf.h b/libpkgconf/libpkgconf.h index 80f87ce..f53f54a 100644 --- a/libpkgconf/libpkgconf.h +++ b/libpkgconf/libpkgconf.h @@ -338,6 +338,7 @@ PKGCONF_API size_t pkgconf_path_build_from_environ(const char *envvarname, const PKGCONF_API bool pkgconf_path_match_list(const char *path, const pkgconf_list_t *dirlist); PKGCONF_API void pkgconf_path_free(pkgconf_list_t *dirlist); PKGCONF_API bool pkgconf_path_relocate(char *buf, size_t buflen); +PKGCONF_API void pkgconf_path_copy_list(pkgconf_list_t *dst, const pkgconf_list_t *src); #ifdef __cplusplus } diff --git a/libpkgconf/path.c b/libpkgconf/path.c index 2f4cfbb..02d1c97 100644 --- a/libpkgconf/path.c +++ b/libpkgconf/path.c @@ -222,6 +222,38 @@ pkgconf_path_match_list(const char *path, const pkgconf_list_t *dirlist) return false; } +/* + * !doc + * + * .. c:function:: void pkgconf_path_copy_list(pkgconf_list_t *dst, const pkgconf_list_t *src) + * + * Copies a path list to another path list. + * + * :param pkgconf_list_t* dst: The path list to copy to. + * :param pkgconf_list_t* src: The path list to copy from. + * :return: nothing + */ +void +pkgconf_path_copy_list(pkgconf_list_t *dst, const pkgconf_list_t *src) +{ + pkgconf_node_t *n; + + PKGCONF_FOREACH_LIST_ENTRY(src->head, n) + { + pkgconf_path_t *srcpath = n->data, *path; + + path = calloc(sizeof(pkgconf_path_t), 1); + path->path = strdup(srcpath->path); + +#ifdef PKGCONF_CACHE_INODES + path->handle_path = srcpath->handle_path; + path->handle_device = srcpath->handle_device; +#endif + + pkgconf_node_insert_tail(&path->lnode, path, dst); + } +} + /* * !doc *