Lines Matching refs:comm_strs
15 static struct comm_strs { struct
32 static struct comm_strs *comm_strs__get(void) in comm_strs__get() argument
99 struct comm_strs *comm_strs = comm_strs__get(); in comm_strs__remove_if_last() local
101 down_write(&comm_strs->lock); in comm_strs__remove_if_last()
109 entry = bsearch(comm_str__str(cs), comm_strs->strs, comm_strs->num_strs, in comm_strs__remove_if_last()
112 for (int i = entry - comm_strs->strs; i < comm_strs->num_strs - 1; i++) in comm_strs__remove_if_last()
113 comm_strs->strs[i] = comm_strs->strs[i + 1]; in comm_strs__remove_if_last()
114 comm_strs->num_strs--; in comm_strs__remove_if_last()
116 up_write(&comm_strs->lock); in comm_strs__remove_if_last()
119 static struct comm_str *__comm_strs__find(struct comm_strs *comm_strs, const char *str) in __comm_strs__find() argument
123 result = bsearch(str, comm_strs->strs, comm_strs->num_strs, sizeof(struct comm_str *), in __comm_strs__find()
134 struct comm_strs *comm_strs = comm_strs__get(); in comm_strs__findnew() local
137 if (!comm_strs) in comm_strs__findnew()
140 down_read(&comm_strs->lock); in comm_strs__findnew()
141 result = __comm_strs__find(comm_strs, str); in comm_strs__findnew()
142 up_read(&comm_strs->lock); in comm_strs__findnew()
146 down_write(&comm_strs->lock); in comm_strs__findnew()
147 result = __comm_strs__find(comm_strs, str); in comm_strs__findnew()
149 if (comm_strs->num_strs == comm_strs->capacity) { in comm_strs__findnew()
152 tmp = reallocarray(comm_strs->strs, in comm_strs__findnew()
153 comm_strs->capacity + 16, in comm_strs__findnew()
154 sizeof(*comm_strs->strs)); in comm_strs__findnew()
156 up_write(&comm_strs->lock); in comm_strs__findnew()
159 comm_strs->strs = tmp; in comm_strs__findnew()
160 comm_strs->capacity += 16; in comm_strs__findnew()
164 int low = 0, high = comm_strs->num_strs - 1; in comm_strs__findnew()
165 int insert = comm_strs->num_strs; /* Default to inserting at the end. */ in comm_strs__findnew()
169 int cmp = strcmp(comm_str__str(comm_strs->strs[mid]), str); in comm_strs__findnew()
178 memmove(&comm_strs->strs[insert + 1], &comm_strs->strs[insert], in comm_strs__findnew()
179 (comm_strs->num_strs - insert) * sizeof(struct comm_str *)); in comm_strs__findnew()
180 comm_strs->num_strs++; in comm_strs__findnew()
181 comm_strs->strs[insert] = result; in comm_strs__findnew()
184 up_write(&comm_strs->lock); in comm_strs__findnew()