Lines Matching defs:t
50 table_t *t;
53 if ((t = calloc((size_t)1, (size_t)(sizeof (table_t) +
60 t->nelem = size;
61 t->used = -1;
62 return (t);
67 add_to_stringtable(table_t *t, char *value)
73 if (t == NULL) {
78 if (in_stringtable(t, value)) {
79 return (t);
81 ++t->used;
82 if (t->used >= t->nelem) {
83 if ((t2 = realloc(t, (size_t)(sizeof (table_t) +
84 ((sizeof (char *)) * (t->nelem + TABLE_INCREMENT)))))
86 print_stringtable(t);
91 t = t2;
92 t->nelem += TABLE_INCREMENT;
93 for (i = t->used; i < t->nelem; ++i) {
94 t->elements[i] = NULL;
97 t->elements[t->used] = strset(t->elements[t->used], value);
98 return (t);
105 free_stringtable(table_t *t)
108 if (t != NULL) {
109 t->used = -1;
111 return (t);
116 get_stringtable(table_t *t, int index)
119 if (t == NULL) {
121 } else if (index > t->used) {
124 return (t->elements[index]);
129 in_stringtable(table_t *t, const char *value)
133 if (t == NULL) {
136 for (i = 0; i <= t->used; ++i) {
137 if (strcmp(value, t->elements[i]) == 0)
145 print_stringtable(table_t *t)
149 if (t == NULL)
154 t->used + 1, t->nelem,
155 sizeof (table_t) + (sizeof (char *) * t->nelem));
157 for (i = 0; i <= t->used; ++i) {
158 (void) fprintf(stderr, "\t%s\n",
159 get_stringtable(t, i));
170 sort_stringtable(table_t *t)
173 if (t && t->used > 0) {
174 qsort((char *)t->elements, (size_t)t->used,