Home | History | Annotate | Download | only in Stringlist

Lines Matching defs:sl

61   StringList *sl;

63 sl = malloc(sizeof(StringList));
64 if (sl == NULL)
67 sl->sl_cur = 0;
68 sl->sl_max = _SL_CHUNKSIZE;
69 sl->sl_str = malloc(sl->sl_max * sizeof(char *));
70 if (sl->sl_str == NULL) {
71 free(sl);
72 sl = NULL;
74 return sl;
82 sl_add(StringList *sl, char *name)
85 _DIAGASSERT(sl != NULL);
87 if (sl->sl_cur == sl->sl_max - 1) {
90 new = realloc(sl->sl_str,
91 (sl->sl_max + _SL_CHUNKSIZE) * sizeof(char *));
94 sl->sl_max += _SL_CHUNKSIZE;
95 sl->sl_str = new;
97 sl->sl_str[sl->sl_cur++] = name;
106 sl_free(StringList *sl, int all)
110 if (sl == NULL)
112 if (sl->sl_str) {
114 for (i = 0; i < sl->sl_cur; i++)
115 free(sl->sl_str[i]);
116 free(sl->sl_str);
118 free(sl);
126 sl_find(StringList *sl, const char *name)
130 _DIAGASSERT(sl != NULL);
132 for (i = 0; i < sl->sl_cur; i++)
133 if (strcmp(sl->sl_str[i], name) == 0)
134 return sl->sl_str[i];
140 sl_delete(StringList *sl, const char *name, int all)
144 for (i = 0; i < sl->sl_cur; i++)
145 if (strcmp(sl->sl_str[i], name) == 0) {
147 free(sl->sl_str[i]);
148 for (j = i + 1; j < sl->sl_cur; j++)
149 sl->sl_str[j - 1] = sl->sl_str[j];
150 sl->sl_str[--sl->sl_cur] = NULL;