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:
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user