From e8938b55964df7b1f051263796ddafa7ae94ee77 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Tue, 15 Jun 2021 22:02:10 +0200 Subject: Fix bug in predefined using_csmap_strv() macro. --- include/stc/cstr.h | 6 +++--- include/stc/csview.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 26d71f91..a3387632 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -284,7 +284,7 @@ cstr_append_n(cstr* self, const char* str, size_t n) { size_t oldlen = _cstr_rep(self)->size, newlen = oldlen + n; if (newlen > _cstr_rep(self)->cap) { size_t off = (size_t) (str - self->str); /* handle self append */ - cstr_reserve(self, newlen*3/2); + cstr_reserve(self, newlen*3 >> 1); if (off <= oldlen) str = self->str + off; } memcpy(&self->str[oldlen], str, n); @@ -297,7 +297,7 @@ STC_INLINE void _cstr_internal_move(cstr* self, size_t pos1, size_t pos2) { return; size_t len = _cstr_rep(self)->size, newlen = len + pos2 - pos1; if (newlen > _cstr_rep(self)->cap) - cstr_reserve(self, newlen*3/2); + cstr_reserve(self, newlen*3 >> 1); memmove(&self->str[pos2], &self->str[pos1], len - pos1); self->str[_cstr_rep(self)->size = newlen] = '\0'; } @@ -349,7 +349,7 @@ cstr_getdelim(cstr *self, int delim, FILE *fp) { return false; for (;;) { if (pos == cap) - cap = cstr_reserve(self, cap*3/2 + 16); + cap = cstr_reserve(self, (cap*3 >> 1) + 24); if (c == delim || c == EOF) { self->str[_cstr_rep(self)->size = pos] = '\0'; return true; diff --git a/include/stc/csview.h b/include/stc/csview.h index 9b65d2e3..e39535a9 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -137,7 +137,7 @@ STC_INLINE bool csview_equals_ref(const csview* a, const csview* b) cstr_del, cstr_from_v, cstr_to_v, csview) #define using_csmap_strv() \ - _c_using_aatree(csmap_strv, csmap_, cstr, cstr, csview_equals_ref, csview_hash_ref, \ + _c_using_aatree(csmap_strv, csmap_, cstr, cstr, csview_compare_ref, \ cstr_del, cstr_from_v, cstr_to_v, csview, c_true, \ cstr_del, cstr_from_v, cstr_to_v, csview) #define using_csset_strv() \ -- cgit v1.2.3