Lines Matching refs:sl

46 	StringList *sl;  in sl_init()  local
48 sl = malloc(sizeof(StringList)); in sl_init()
49 if (sl == NULL) in sl_init()
52 sl->sl_cur = 0; in sl_init()
53 sl->sl_max = _SL_CHUNKSIZE; in sl_init()
54 sl->sl_str = reallocarray(NULL, sl->sl_max, sizeof(char *)); in sl_init()
55 if (sl->sl_str == NULL) { in sl_init()
56 free(sl); in sl_init()
57 sl = NULL; in sl_init()
59 return sl; in sl_init()
67 sl_add(StringList *sl, char *name) in sl_add() argument
69 if (sl->sl_cur == sl->sl_max - 1) { in sl_add()
72 new = reallocarray(sl->sl_str, (sl->sl_max + _SL_CHUNKSIZE), in sl_add()
76 sl->sl_max += _SL_CHUNKSIZE; in sl_add()
77 sl->sl_str = new; in sl_add()
79 sl->sl_str[sl->sl_cur++] = name; in sl_add()
88 sl_free(StringList *sl, int all) in sl_free() argument
92 if (sl == NULL) in sl_free()
94 if (sl->sl_str) { in sl_free()
96 for (i = 0; i < sl->sl_cur; i++) in sl_free()
97 free(sl->sl_str[i]); in sl_free()
98 free(sl->sl_str); in sl_free()
100 free(sl); in sl_free()
108 sl_find(StringList *sl, const char *name) in sl_find() argument
112 for (i = 0; i < sl->sl_cur; i++) in sl_find()
113 if (strcmp(sl->sl_str[i], name) == 0) in sl_find()
114 return sl->sl_str[i]; in sl_find()
120 sl_delete(StringList *sl, const char *name, int all) in sl_delete() argument
124 for (i = 0; i < sl->sl_cur; i++) in sl_delete()
125 if (strcmp(sl->sl_str[i], name) == 0) { in sl_delete()
127 free(sl->sl_str[i]); in sl_delete()
128 for (j = i + 1; j < sl->sl_cur; j++) in sl_delete()
129 sl->sl_str[j - 1] = sl->sl_str[j]; in sl_delete()
130 sl->sl_str[--sl->sl_cur] = NULL; in sl_delete()