Skip to content

Commit 6e91820

Browse files
committed
Fixed bug in csmap.h: begin() on empty map not inited correctly. Moved cstr_from_sv() from csview.h to cstr.h
1 parent 1616224 commit 6e91820

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

include/stc/csmap.h

+1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ _cx_memb(_shrink_to_fit)(_cx_self *self) {
200200
STC_INLINE _cx_iter
201201
_cx_memb(_begin)(const _cx_self* self) {
202202
_cx_iter it;
203+
it.ref = NULL;
203204
it._d = self->nodes, it._top = 0;
204205
it._tn = (i_size) _csmap_rep(self)->root;
205206
if (it._tn)

include/stc/cstr.h

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ STC_INLINE cstr cstr_from_n(const char* str, const size_t len) {
111111
STC_INLINE cstr cstr_from(const char* str)
112112
{ return cstr_from_n(str, strlen(str)); }
113113

114+
STC_INLINE cstr cstr_from_sv(csview sv)
115+
{ return cstr_from_n(sv.str, sv.size); }
116+
114117
STC_INLINE cstr cstr_with_size(const size_t size, const char value) {
115118
cstr s;
116119
memset(_cstr_init(&s, size, size), value, size);

include/stc/csview.h

-3
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ STC_INLINE bool csview_valid_utf8(csview sv) // depends on src/utf8code.c
108108
STC_INLINE csview csview_from_s(const cstr* self)
109109
{ return c_make(csview){cstr_str(self), cstr_size(*self)}; }
110110

111-
STC_INLINE cstr cstr_from_sv(csview sv)
112-
{ return cstr_from_n(sv.str, sv.size); }
113-
114111
STC_INLINE csview cstr_substr(const cstr* self, size_t pos, size_t n)
115112
{ return csview_substr(csview_from_s(self), pos, n); }
116113

0 commit comments

Comments
 (0)