Lines Matching defs:zsp
72 zed_strings_t *zsp;
74 zsp = calloc(1, sizeof (*zsp));
75 if (!zsp)
78 avl_create(&zsp->tree, _zed_strings_node_compare,
81 zsp->iteratorp = NULL;
82 return (zsp);
141 * Destroy the string container [zsp] and all nodes within.
144 zed_strings_destroy(zed_strings_t *zsp)
149 if (!zsp)
153 while ((np = avl_destroy_nodes(&zsp->tree, &cookie)))
156 avl_destroy(&zsp->tree);
157 free(zsp);
161 * Add a copy of the string [s] indexed by [key] to the container [zsp].
162 * If [key] already exists within the container [zsp], it will be replaced
168 zed_strings_add(zed_strings_t *zsp, const char *key, const char *s)
172 if (!zsp || !s) {
183 oldp = avl_find(&zsp->tree, newp, NULL);
185 avl_remove(&zsp->tree, oldp);
188 avl_add(&zsp->tree, newp);
193 * Return the first string in container [zsp].
195 * This can be called multiple times to re-traverse [zsp].
199 zed_strings_first(zed_strings_t *zsp)
201 if (!zsp) {
205 zsp->iteratorp = avl_first(&zsp->tree);
206 if (!zsp->iteratorp)
209 return (((zed_strings_node_t *)zsp->iteratorp)->val);
214 * Return the next string in container [zsp].
220 zed_strings_next(zed_strings_t *zsp)
222 if (!zsp) {
226 if (!zsp->iteratorp)
229 zsp->iteratorp = AVL_NEXT(&zsp->tree, zsp->iteratorp);
230 if (!zsp->iteratorp)
233 return (((zed_strings_node_t *)zsp->iteratorp)->val);
237 * Return the number of strings in container [zsp], or -1 on error.
240 zed_strings_count(zed_strings_t *zsp)
242 if (!zsp) {
246 return (avl_numnodes(&zsp->tree));