summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-06-15 22:02:10 +0200
committerTyge Løvset <[email protected]>2021-06-15 22:02:10 +0200
commite8938b55964df7b1f051263796ddafa7ae94ee77 (patch)
treede24cdf907c50d270ae79bb2477bd0c0f57a46cd
parent0e52b558cbe7cd3ac54bf3aba88c5679c43d6e39 (diff)
downloadSTC-modified-e8938b55964df7b1f051263796ddafa7ae94ee77.tar.gz
STC-modified-e8938b55964df7b1f051263796ddafa7ae94ee77.zip
Fix bug in predefined using_csmap_strv() macro.
-rw-r--r--include/stc/cstr.h6
-rw-r--r--include/stc/csview.h2
2 files changed, 4 insertions, 4 deletions
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() \