Lines Matching defs:g
45 group_create(group_t *g)
47 bzero(g, sizeof (group_t));
55 group_destroy(group_t *g)
57 ASSERT(g->grp_size == 0);
59 if (g->grp_capacity > 0) {
60 kmem_free(g->grp_set, g->grp_capacity * sizeof (void *));
61 g->grp_capacity = 0;
63 g->grp_set = NULL;
71 group_empty(group_t *g)
74 int sz = g->grp_size;
76 g->grp_size = 0;
78 g->grp_set[i] = NULL;
82 * Add element "e" to group "g"
88 group_add(group_t *g, void *e, int gflag)
93 g->grp_size == g->grp_capacity)
96 ASSERT(g->grp_size != g->grp_capacity || (gflag & GRP_RESIZE));
98 entry = g->grp_size++;
99 if (g->grp_size > g->grp_capacity)
100 group_grow_set(g);
102 ASSERT(g->grp_set[entry] == NULL);
103 g->grp_set[entry] = e;
109 * Remove element "e" from group "g"
111 * Returns -1 if "e" was not present in "g" and 0 otherwise
114 group_remove(group_t *g, void *e, int gflag)
118 if (g->grp_size == 0)
124 for (i = 0; i < g->grp_size; i++)
125 if (g->grp_set[i] == e)
127 if (g->grp_set[i] != e)
130 g->grp_set[i] = NULL;
131 group_pack_set(g->grp_set, g->grp_size);
132 g->grp_size--;
135 g->grp_size > GRP_SET_SIZE_DEFAULT && ISP2(g->grp_size))
136 group_shrink_set(g);
142 * Expand the capacity of group "g" so that it may
146 group_expand(group_t *g, uint_t n)
148 while (g->grp_capacity < n)
149 group_grow_set(g);
156 group_grow_set(group_t *g)
161 cap_old = g->grp_capacity;
162 set_old = g->grp_set;
173 g->grp_set = kmem_zalloc(cap_new * sizeof (void *), KM_SLEEP);
174 g->grp_capacity = cap_new;
182 g->grp_set = set_new;
183 g->grp_capacity = cap_new;
196 group_shrink_set(group_t *g)
201 cap_old = g->grp_capacity;
202 set_old = g->grp_set;
219 g->grp_capacity = cap_new;
220 g->grp_set = set_new;
282 group_iterate(group_t *g, group_iter_t *iter)
287 while (idx < g->grp_size) {
288 data = g->grp_set[idx++];
301 group_access_at(group_t *g, uint_t idx)
303 if (idx >= g->grp_capacity)
306 return (g->grp_set[idx]);
318 group_add_at(group_t *g, void *e, uint_t idx)
320 if (idx >= g->grp_capacity)
323 if (idx >= g->grp_size)
324 g->grp_size = idx + 1;
326 ASSERT(g->grp_set[idx] == NULL);
327 g->grp_set[idx] = e;
335 group_remove_at(group_t *g, uint_t idx)
337 ASSERT(idx < g->grp_capacity);
338 g->grp_set[idx] = NULL;
346 group_find(group_t *g, void *e)
350 for (idx = 0; idx < g->grp_capacity; idx++) {
351 if (g->grp_set[idx] == e)