forked from ariadne/pkgconf
fragment: add pkg_fragment_exists() and use it to mergemaster in pkg_fragment_copy().
parent
a4a572f608
commit
26c5dcb125
20
fragment.c
20
fragment.c
|
@ -66,11 +66,31 @@ pkg_fragment_add(pkg_fragment_t *head, const char *string)
|
|||
return pkg_fragment_append(head, frag);
|
||||
}
|
||||
|
||||
bool
|
||||
pkg_fragment_exists(pkg_fragment_t *head, pkg_fragment_t *base)
|
||||
{
|
||||
pkg_fragment_t *node;
|
||||
|
||||
foreach_list_entry(head, node)
|
||||
{
|
||||
if (base->type != node->type)
|
||||
continue;
|
||||
|
||||
if (!strcmp(base->data, node->data))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
pkg_fragment_t *
|
||||
pkg_fragment_copy(pkg_fragment_t *head, pkg_fragment_t *base)
|
||||
{
|
||||
pkg_fragment_t *frag;
|
||||
|
||||
if (pkg_fragment_exists(head, base))
|
||||
return head;
|
||||
|
||||
frag = calloc(sizeof(pkg_fragment_t), 1);
|
||||
|
||||
frag->type = base->type;
|
||||
|
|
1
pkg.h
1
pkg.h
|
@ -138,5 +138,6 @@ 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_copy(pkg_fragment_t *head, pkg_fragment_t *base);
|
||||
void pkg_fragment_delete(pkg_fragment_t *node);
|
||||
bool pkg_fragment_exists(pkg_fragment_t *head, pkg_fragment_t *base);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue