2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-01 06:45:38 +00:00

Make value_list generic so it can be reused.

value_list can be reused by conditionals and list values, so pull it out
and abstract it some more.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Kees Cook <kees@ubuntu.com>
This commit is contained in:
John Johansen
2012-02-16 08:07:28 -08:00
parent e087db57b2
commit b8f36df713
3 changed files with 51 additions and 29 deletions

View File

@@ -939,6 +939,41 @@ void debug_cod_list(struct codomain *cod)
dump_policy_hats(cod);
}
struct value_list *new_value_list(char *value)
{
struct value_list *val = calloc(1, sizeof(struct value_list));
if (val)
val->value = value;
return val;
}
void free_value_list(struct value_list *list)
{
struct value_list *next;
while (list) {
next = list->next;
if (list->value)
free(list->value);
free(list);
list = next;
}
}
void print_value_list(struct value_list *list)
{
struct value_list *entry;
if (!list)
return;
fprintf(stderr, "%s", list->value);
list = list->next;
list_for_each(list, entry) {
fprintf(stderr, ", %s", entry->value);
}
}
#ifdef UNIT_TEST
int test_str_to_boolean(void)
{