=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sndiod/utils.c,v retrieving revision 1.5 retrieving revision 1.6 diff -c -r1.5 -r1.6 *** src/usr.bin/sndiod/utils.c 2019/07/05 07:34:40 1.5 --- src/usr.bin/sndiod/utils.c 2019/09/21 04:42:46 1.6 *************** *** 1,4 **** ! /* $OpenBSD: utils.c,v 1.5 2019/07/05 07:34:40 ratchov Exp $ */ /* * Copyright (c) 2003-2012 Alexandre Ratchov * --- 1,4 ---- ! /* $OpenBSD: utils.c,v 1.6 2019/09/21 04:42:46 ratchov Exp $ */ /* * Copyright (c) 2003-2012 Alexandre Ratchov * *************** *** 187,190 **** --- 187,217 ---- p = xmalloc(size); memcpy(p, s, size); return p; + } + + /* + * copy and append the given string to the name list + */ + void + namelist_add(struct name **list, char *str) + { + struct name *n; + size_t size; + + size = strlen(str) + 1; + n = xmalloc(sizeof(struct name) + size); + memcpy(n->str, str, size); + n->next = *list; + *list = n; + } + + void + namelist_clear(struct name **list) + { + struct name *n; + + while ((n = *list) != NULL) { + *list = n->next; + xfree(n); + } }