1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-04-27 10:50:38 +03:00
lvm2/lib/datastruct/str_list.c
2003-09-17 20:35:57 +00:00

36 lines
538 B
C

/*
* Copyright (C) 2003 Sistina Software
*
* This file is released under the LGPL.
*/
#include "lib.h"
#include "str_list.h"
int str_list_add(struct pool *mem, struct list *sl, const char *str)
{
struct str_list *sln;
struct list *slh;
if (!str) {
stack;
return 0;
}
/* Already in list? */
list_iterate(slh, sl) {
if (!strcmp(str, list_item(slh, struct str_list)->str))
return 1;
}
if (!(sln = pool_alloc(mem, sizeof(*sln)))) {
stack;
return 0;
}
sln->str = str;
list_add(sl, &sln->list);
return 1;
}