diff --git a/pkg.c b/pkg.c index b84f847..8838cb1 100644 --- a/pkg.c +++ b/pkg.c @@ -70,6 +70,43 @@ str_has_suffix(const char *str, const char *suffix) return !strncasecmp(str + str_len - suf_len, suffix, suf_len); } +void +pkg_free(pkg_t *pkg) +{ + if (pkg->id != NULL) + free(pkg->id); + + if (pkg->filename != NULL) + free(pkg->filename); + + if (pkg->realname != NULL) + free(pkg->realname); + + if (pkg->version != NULL) + free(pkg->version); + + if (pkg->description != NULL) + free(pkg->description); + + if (pkg->url != NULL) + free(pkg->url); + + if (pkg->pc_filedir != NULL) + free(pkg->pc_filedir); + + pkg_dependency_free(pkg->requires); + pkg_dependency_free(pkg->requires_private); + pkg_dependency_free(pkg->conflicts); + + pkg_fragment_free(pkg->cflags); + pkg_fragment_free(pkg->libs); + pkg_fragment_free(pkg->libs_private); + + pkg_tuple_free(pkg->vars); + + free(pkg); +} + pkg_t * pkg_find(const char *name, unsigned int flags) { diff --git a/pkg.h b/pkg.h index fa22e58..9efc65f 100644 --- a/pkg.h +++ b/pkg.h @@ -129,6 +129,8 @@ struct pkg_ { #define PKG_ERRF_PACKAGE_NOT_FOUND 0x1 #define PKG_ERRF_PACKAGE_VER_MISMATCH 0x2 +/* pkg.c */ +void pkg_free(pkg_t *pkg); pkg_t *pkg_find(const char *name, unsigned int flags); void pkg_traverse(pkg_t *root, void (*pkg_traverse_func)(pkg_t *package, void *data), void *data, int maxdepth, unsigned int flags); void pkg_verify_graph(pkg_t *root, int depth, unsigned int flags);