Lines Matching defs:l
62 item_add(itemlist l, char *s)
64 if (l->nallocated < 0) {
66 l->nallocated = l->nused + ALLOCCHUNK;
67 new = malloc(sizeof (char *) * l->nused);
68 memcpy(new, l->items, l->nused * sizeof (char *));
69 l->items = new;
70 } else if (l->nallocated == l->nused) {
71 if (l->nallocated)
72 l->nallocated *= 2;
74 l->nallocated = ALLOCCHUNK;
75 l->items = realloc(l->items, sizeof (char *) * l->nallocated);
77 l->items[l->nused++] = s;
78 l->sorted = l->nused <= 1;
82 item_add_list(itemlist l, char **s, int n, int alloc)
84 if (l->nallocated == 0) {
85 l->items = s;
86 l->nallocated = alloc ? n : -1;
87 l->nused = n;
88 l->sorted = 0;
93 item_add(l, s[i]);
101 item_addfile(itemlist l, const char *fname)
114 item_add(l, strdup(buf));
128 item_search(itemlist l, const char *s)
131 int hi = l->nused - 1;
133 if (!l->sorted) {
134 qsort(l->items, l->nused, sizeof (char *), xcmp);
135 l->sorted = 1;
140 int res = strcmp(s, l->items[mid]);
153 *item_get(itemlist l, int i)
155 if (i >= l->nused || i < 0)
158 return (l->items[i]);