(#2) Add str_list_free utility function
This commit is contained in:
parent
4cc793fcda
commit
98208b511b
5
util.c
5
util.c
|
@ -117,3 +117,8 @@ struct str_list str_list_new(int count, ...)
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void str_list_free(struct str_list* l) {
|
||||||
|
for (int i = 0; i < l->size; i++) {
|
||||||
|
free(l->values[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
2
util.h
2
util.h
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: It's probably considered bad practice to define macros in lower-case...
|
* TODO: It's probably considered bad practice to define macros in lower-case...
|
||||||
* TODO: str_list_free
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SHIFT_ARGS() argv++; argc--
|
#define SHIFT_ARGS() argv++; argc--
|
||||||
|
@ -27,5 +26,6 @@ struct str_list {
|
||||||
|
|
||||||
struct str_list* str_list_add(struct str_list* l, char* s);
|
struct str_list* str_list_add(struct str_list* l, char* s);
|
||||||
struct str_list str_list_new(int count, ...);
|
struct str_list str_list_new(int count, ...);
|
||||||
|
void str_list_free(struct str_list* l);
|
||||||
#define str_list_init() str_list_new(0)
|
#define str_list_init() str_list_new(0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue