pkg: add pkg_free()

feature/tap-sh
William Pitcock 2012-05-06 20:30:50 -05:00
parent 9b540397f0
commit 3eb16dca0f
2 changed files with 39 additions and 0 deletions

37
pkg.c
View File

@ -70,6 +70,43 @@ str_has_suffix(const char *str, const char *suffix)
return !strncasecmp(str + str_len - suf_len, suffix, suf_len); 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_t *
pkg_find(const char *name, unsigned int flags) pkg_find(const char *name, unsigned int flags)
{ {

2
pkg.h
View File

@ -129,6 +129,8 @@ struct pkg_ {
#define PKG_ERRF_PACKAGE_NOT_FOUND 0x1 #define PKG_ERRF_PACKAGE_NOT_FOUND 0x1
#define PKG_ERRF_PACKAGE_VER_MISMATCH 0x2 #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); 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_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); void pkg_verify_graph(pkg_t *root, int depth, unsigned int flags);