comm_strs
struct comm_strs *comm_strs = comm_strs__get();
down_write(&comm_strs->lock);
entry = bsearch(comm_str__str(cs), comm_strs->strs, comm_strs->num_strs,
for (int i = entry - comm_strs->strs; i < comm_strs->num_strs - 1; i++)
comm_strs->strs[i] = comm_strs->strs[i + 1];
comm_strs->num_strs--;
up_write(&comm_strs->lock);
static struct comm_str *__comm_strs__find(struct comm_strs *comm_strs, const char *str)
SHARED_LOCKS_REQUIRED(comm_strs->lock)
result = bsearch(str, comm_strs->strs, comm_strs->num_strs, sizeof(struct comm_str *),
struct comm_strs *comm_strs = comm_strs__get();
if (!comm_strs)
down_read(&comm_strs->lock);
result = __comm_strs__find(comm_strs, str);
up_read(&comm_strs->lock);
down_write(&comm_strs->lock);
result = __comm_strs__find(comm_strs, str);
if (comm_strs->num_strs == comm_strs->capacity) {
tmp = reallocarray(comm_strs->strs,
comm_strs->capacity + 16,
sizeof(*comm_strs->strs));
up_write(&comm_strs->lock);
comm_strs->strs = tmp;
comm_strs->capacity += 16;
int low = 0, high = comm_strs->num_strs - 1;
int insert = comm_strs->num_strs; /* Default to inserting at the end. */
int cmp = strcmp(comm_str__str(comm_strs->strs[mid]), str);
memmove(&comm_strs->strs[insert + 1], &comm_strs->strs[insert],
(comm_strs->num_strs - insert) * sizeof(struct comm_str *));
comm_strs->num_strs++;
comm_strs->strs[insert] = result;
up_write(&comm_strs->lock);
static struct comm_strs *comm_strs__get(void)