Lines Matching refs:comm_strs
17 static struct comm_strs { struct
35 static struct comm_strs *comm_strs__get(void) in comm_strs__get() argument
102 struct comm_strs *comm_strs = comm_strs__get(); in comm_strs__remove_if_last() local
104 down_write(&comm_strs->lock); in comm_strs__remove_if_last()
112 entry = bsearch(comm_str__str(cs), comm_strs->strs, comm_strs->num_strs, in comm_strs__remove_if_last()
115 for (int i = entry - comm_strs->strs; i < comm_strs->num_strs - 1; i++) in comm_strs__remove_if_last()
116 comm_strs->strs[i] = comm_strs->strs[i + 1]; in comm_strs__remove_if_last()
117 comm_strs->num_strs--; in comm_strs__remove_if_last()
119 up_write(&comm_strs->lock); in comm_strs__remove_if_last()
122 static struct comm_str *__comm_strs__find(struct comm_strs *comm_strs, const char *str) in __comm_strs__find() argument
123 SHARED_LOCKS_REQUIRED(comm_strs->lock) in __comm_strs__find()
127 result = bsearch(str, comm_strs->strs, comm_strs->num_strs, sizeof(struct comm_str *), in __comm_strs__find()
138 struct comm_strs *comm_strs = comm_strs__get(); in comm_strs__findnew() local
141 if (!comm_strs) in comm_strs__findnew()
144 down_read(&comm_strs->lock); in comm_strs__findnew()
145 result = __comm_strs__find(comm_strs, str); in comm_strs__findnew()
146 up_read(&comm_strs->lock); in comm_strs__findnew()
150 down_write(&comm_strs->lock); in comm_strs__findnew()
151 result = __comm_strs__find(comm_strs, str); in comm_strs__findnew()
153 if (comm_strs->num_strs == comm_strs->capacity) { in comm_strs__findnew()
156 tmp = reallocarray(comm_strs->strs, in comm_strs__findnew()
157 comm_strs->capacity + 16, in comm_strs__findnew()
158 sizeof(*comm_strs->strs)); in comm_strs__findnew()
160 up_write(&comm_strs->lock); in comm_strs__findnew()
163 comm_strs->strs = tmp; in comm_strs__findnew()
164 comm_strs->capacity += 16; in comm_strs__findnew()
168 int low = 0, high = comm_strs->num_strs - 1; in comm_strs__findnew()
169 int insert = comm_strs->num_strs; /* Default to inserting at the end. */ in comm_strs__findnew()
173 int cmp = strcmp(comm_str__str(comm_strs->strs[mid]), str); in comm_strs__findnew()
182 memmove(&comm_strs->strs[insert + 1], &comm_strs->strs[insert], in comm_strs__findnew()
183 (comm_strs->num_strs - insert) * sizeof(struct comm_str *)); in comm_strs__findnew()
184 comm_strs->num_strs++; in comm_strs__findnew()
185 comm_strs->strs[insert] = result; in comm_strs__findnew()
188 up_write(&comm_strs->lock); in comm_strs__findnew()