fragment: add pkg_fragment_copy().

pull/15/head
William Pitcock 2012-05-03 20:31:33 +00:00
parent c1e5ab046b
commit d94ab7555d
2 changed files with 14 additions and 0 deletions

View File

@ -66,6 +66,19 @@ pkg_fragment_add(pkg_fragment_t *head, const char *string)
return pkg_fragment_append(head, frag); return pkg_fragment_append(head, frag);
} }
pkg_fragment_t *
pkg_fragment_copy(pkg_fragment_t *head, pkg_fragment_t *base)
{
pkg_fragment_t *frag;
frag = calloc(sizeof(pkg_fragment_t), 1);
frag->type = base->type;
frag->data = strdup(base->data);
return pkg_fragment_append(head, frag);
}
void void
pkg_fragment_delete(pkg_fragment_t *node) pkg_fragment_delete(pkg_fragment_t *node)
{ {

1
pkg.h
View File

@ -136,6 +136,7 @@ int argv_split(const char *src, int *argc, char ***argv);
/* fragment.c */ /* fragment.c */
pkg_fragment_t *pkg_fragment_append(pkg_fragment_t *head, pkg_fragment_t *tail); pkg_fragment_t *pkg_fragment_append(pkg_fragment_t *head, pkg_fragment_t *tail);
pkg_fragment_t *pkg_fragment_add(pkg_fragment_t *head, const char *string); pkg_fragment_t *pkg_fragment_add(pkg_fragment_t *head, const char *string);
pkg_fragment_t *pkg_fragment_copy(pkg_fragment_t *head, pkg_fragment_t *base);
void pkg_fragment_delete(pkg_fragment_t *node); void pkg_fragment_delete(pkg_fragment_t *node);
#endif #endif