Skip to content

Commit

Permalink
Fixed bug in csmap.h: begin() on empty map not inited correctly. Move…
Browse files Browse the repository at this point in the history
…d cstr_from_sv() from csview.h to cstr.h
  • Loading branch information
tylov committed Jun 27, 2022
1 parent 1616224 commit 6e91820
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/stc/csmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions include/stc/cstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions include/stc/csview.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand Down

0 comments on commit 6e91820

Please sign in to comment.