From 6e91820d7cf632ff30b936c554a0bdf83c9e64b2 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Mon, 27 Jun 2022 22:58:17 +0200 Subject: Fixed bug in csmap.h: begin() on empty map not inited correctly. Moved cstr_from_sv() from csview.h to cstr.h --- include/stc/csmap.h | 1 + include/stc/cstr.h | 3 +++ include/stc/csview.h | 3 --- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/stc/csmap.h b/include/stc/csmap.h index a463d381..5af28830 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -200,6 +200,7 @@ _cx_memb(_shrink_to_fit)(_cx_self *self) { STC_INLINE _cx_iter _cx_memb(_begin)(const _cx_self* self) { _cx_iter it; + it.ref = NULL; it._d = self->nodes, it._top = 0; it._tn = (i_size) _csmap_rep(self)->root; if (it._tn) diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 00912576..ed533064 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -111,6 +111,9 @@ STC_INLINE cstr cstr_from_n(const char* str, const size_t len) { STC_INLINE cstr cstr_from(const char* str) { return cstr_from_n(str, strlen(str)); } +STC_INLINE cstr cstr_from_sv(csview sv) + { return cstr_from_n(sv.str, sv.size); } + STC_INLINE cstr cstr_with_size(const size_t size, const char value) { cstr s; memset(_cstr_init(&s, size, size), value, size); diff --git a/include/stc/csview.h b/include/stc/csview.h index 31a3ccba..e74ce844 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -108,9 +108,6 @@ STC_INLINE bool csview_valid_utf8(csview sv) // depends on src/utf8code.c STC_INLINE csview csview_from_s(const cstr* self) { return c_make(csview){cstr_str(self), cstr_size(*self)}; } -STC_INLINE cstr cstr_from_sv(csview sv) - { return cstr_from_n(sv.str, sv.size); } - STC_INLINE csview cstr_substr(const cstr* self, size_t pos, size_t n) { return csview_substr(csview_from_s(self), pos, n); } -- cgit v1.2.3