diff options
| author | Tyge Løvset <[email protected]> | 2022-06-21 13:42:05 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-06-21 13:47:45 +0200 |
| commit | 161622453ad44a29dc52f496c2d721d41255e45f (patch) | |
| tree | 816bda8a79aae5ee404e76751830fb292eb0328a | |
| parent | c7e46d06e90483db30bcccce0a0f1d709661c5fc (diff) | |
| download | STC-modified-161622453ad44a29dc52f496c2d721d41255e45f.tar.gz STC-modified-161622453ad44a29dc52f496c2d721d41255e45f.zip | |
Renamed expand_uninit() functions to insert_uninit() / append_uninit().
| -rw-r--r-- | docs/cstack_api.md | 2 | ||||
| -rw-r--r-- | docs/cstr_api.md | 2 | ||||
| -rw-r--r-- | docs/cvec_api.md | 2 | ||||
| -rw-r--r-- | include/stc/alt/cstr.h | 2 | ||||
| -rw-r--r-- | include/stc/cdeq.h | 8 | ||||
| -rw-r--r-- | include/stc/cstack.h | 2 | ||||
| -rw-r--r-- | include/stc/cstr.h | 11 | ||||
| -rw-r--r-- | include/stc/cvec.h | 14 |
8 files changed, 22 insertions, 21 deletions
diff --git a/docs/cstack_api.md b/docs/cstack_api.md index 0c5933d0..a72153e1 100644 --- a/docs/cstack_api.md +++ b/docs/cstack_api.md @@ -31,7 +31,7 @@ cstack_X cstack_X_clone(cstack_X st); void cstack_X_clear(cstack_X* self); bool cstack_X_reserve(cstack_X* self, size_t n); void cstack_X_shrink_to_fit(cstack_X* self); -i_val* cstack_X_expand_uninit(cstack_X* self, size_t n); +i_val* cstack_X_append_uninit(cstack_X* self, size_t n); void cstack_X_copy(cstack_X* self, cstack_X other); void cstack_X_drop(cstack_X* self); // destructor diff --git a/docs/cstr_api.md b/docs/cstr_api.md index 2be24dfc..071da20a 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -43,7 +43,7 @@ bool cstr_empty(cstr s); size_t cstr_reserve(cstr* self, size_t capacity); void cstr_resize(cstr* self, size_t len, char fill); void cstr_shrink_to_fit(cstr* self); -char* cstr_expand_uninit(cstr* self, size_t n); // return ptr to uninit data +char* cstr_append_uninit(cstr* self, size_t len); // return ptr to uninit data void cstr_clear(cstr* self); char* cstr_assign(cstr* self, const char* str); diff --git a/docs/cvec_api.md b/docs/cvec_api.md index 2ea52e56..e504954c 100644 --- a/docs/cvec_api.md +++ b/docs/cvec_api.md @@ -36,7 +36,7 @@ void cvec_X_clear(cvec_X* self); void cvec_X_copy(cvec_X* self, cvec_X other); bool cvec_X_reserve(cvec_X* self, size_t cap); bool cvec_X_resize(cvec_X* self, size_t size, i_val null); -cvec_X_value* cvec_X_expand_uninit(cvec_X* self, size_t n); // return start of uninit +cvec_X_value* cvec_X_append_uninit(cvec_X* self, size_t n); // return start of uninit void cvec_X_shrink_to_fit(cvec_X* self); void cvec_X_swap(cvec_X* a, cvec_X* b); void cvec_X_drop(cvec_X* self); // destructor diff --git a/include/stc/alt/cstr.h b/include/stc/alt/cstr.h index 8b0362d2..77067740 100644 --- a/include/stc/alt/cstr.h +++ b/include/stc/alt/cstr.h @@ -136,7 +136,7 @@ STC_INLINE cstr cstr_with_size(const size_t len, const char fill) { return s; } -STC_INLINE char* cstr_expand_uninit(cstr *self, size_t n) { +STC_INLINE char* cstr_append_uninit(cstr *self, size_t n) { size_t len = cstr_size(*self); char* d; if (!(d = cstr_reserve(self, len + n))) return NULL; _cstr_p(self)->size += n; diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index afe01165..9c706e52 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -344,7 +344,7 @@ _cx_memb(_expand_left_half_)(_cx_self* self, const size_t idx, const size_t n) { } static _cx_value* -_cx_memb(_expand_uninit_p)(_cx_self* self, const _cx_value* pos, const size_t n) { +_cx_memb(_insert_uninit_p)(_cx_self* self, const _cx_value* pos, const size_t n) { const size_t idx = pos - self->data; if (idx*2 < cdeq_rep_(self)->size) _cx_memb(_expand_left_half_)(self, idx, n); @@ -369,7 +369,7 @@ _cx_memb(_push_front)(_cx_self* self, i_key value) { STC_DEF _cx_value* _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos, const _cx_value* p1, const _cx_value* p2) { - pos = _cx_memb(_expand_uninit_p)(self, pos, p2 - p1); + pos = _cx_memb(_insert_uninit_p)(self, pos, p2 - p1); if (pos) memcpy(pos, p1, (p2 - p1)*sizeof *p1); return pos; @@ -393,7 +393,7 @@ _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2) { #if !defined _i_no_emplace STC_DEF _cx_value* _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, const _cx_raw* p1, const _cx_raw* p2) { - pos = _cx_memb(_expand_uninit_p)(self, pos, p2 - p1); + pos = _cx_memb(_insert_uninit_p)(self, pos, p2 - p1); _cx_value* it = pos; if (pos) for (; p1 != p2; ++p1) *pos++ = i_keyfrom((*p1)); @@ -404,7 +404,7 @@ _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, const _cx_raw* p1, co STC_DEF _cx_value* _cx_memb(_clone_range_p)(_cx_self* self, _cx_value* pos, const _cx_value* p1, const _cx_value* p2) { - pos = _cx_memb(_expand_uninit_p)(self, pos, p2 - p1); + pos = _cx_memb(_insert_uninit_p)(self, pos, p2 - p1); _cx_value* it = pos; if (pos) for (; p1 != p2; ++p1) *pos++ = i_keyclone((*p1)); diff --git a/include/stc/cstack.h b/include/stc/cstack.h index 52137d33..b9cff196 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -78,7 +78,7 @@ STC_INLINE bool _cx_memb(_reserve)(_cx_self* self, size_t n) { } STC_INLINE _cx_value* -_cx_memb(_expand_uninit)(_cx_self *self, size_t n) { +_cx_memb(_append_uninit)(_cx_self *self, size_t n) { size_t len = self->size; if (!_cx_memb(_reserve)(self, len + n)) return NULL; self->size += n; diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 9b872bd0..00912576 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -218,11 +218,12 @@ STC_INLINE void cstr_next(cstr_iter* it) { STC_INLINE void cstr_clear(cstr* self) { _cstr_set_size(self, 0); } -STC_INLINE char* cstr_expand_uninit(cstr *self, size_t n) { - size_t len = cstr_size(*self); char* d; - if (!(d = cstr_reserve(self, len + n))) return NULL; - _cstr_set_size(self, len + n); - return d + len; +STC_INLINE char* cstr_append_uninit(cstr *self, size_t len) { + size_t sz = cstr_size(*self); + char* d = cstr_reserve(self, sz + len); + if (!d) return NULL; + _cstr_set_size(self, sz + len); + return d + sz; } STC_INLINE int cstr_cmp(const cstr* s1, const cstr* s2) diff --git a/include/stc/cvec.h b/include/stc/cvec.h index cd9c8f9e..77462a30 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -86,7 +86,7 @@ STC_API _cx_value* _cx_memb(_push)(_cx_self* self, i_key value); STC_API _cx_iter _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2); STC_API _cx_value* _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos, const _cx_value* p1, const _cx_value* p2); -STC_API _cx_value* _cx_memb(_expand_uninit_p)(_cx_self* self, _cx_value* pos, const size_t n); +STC_API _cx_value* _cx_memb(_insert_uninit_p)(_cx_self* self, _cx_value* pos, const size_t n); #if !c_option(c_no_cmp) STC_API int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y); STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, _cx_raw raw); @@ -168,8 +168,8 @@ _cx_memb(_shrink_to_fit)(_cx_self *self) { } STC_INLINE _cx_value* -_cx_memb(_expand_uninit)(_cx_self *self, const size_t n) { - return _cx_memb(_expand_uninit_p)(self, self->data + _cx_memb(_size)(*self), n); +_cx_memb(_append_uninit)(_cx_self *self, const size_t n) { + return _cx_memb(_insert_uninit_p)(self, self->data + _cx_memb(_size)(*self), n); } STC_INLINE _cx_value* @@ -325,7 +325,7 @@ _cx_memb(_push)(_cx_self* self, i_key value) { } STC_DEF _cx_value* -_cx_memb(_expand_uninit_p)(_cx_self* self, _cx_value* pos, const size_t n) { +_cx_memb(_insert_uninit_p)(_cx_self* self, _cx_value* pos, const size_t n) { const size_t idx = pos - self->data; struct cvec_rep* r = cvec_rep_(self); if (!n) @@ -344,7 +344,7 @@ _cx_memb(_expand_uninit_p)(_cx_self* self, _cx_value* pos, const size_t n) { STC_DEF _cx_value* _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos, const _cx_value* p1, const _cx_value* p2) { - pos = _cx_memb(_expand_uninit_p)(self, pos, p2 - p1); + pos = _cx_memb(_insert_uninit_p)(self, pos, p2 - p1); if (pos) memcpy(pos, p1, (p2 - p1)*sizeof *p1); return pos; @@ -376,7 +376,7 @@ _cx_memb(_clone)(_cx_self cx) { STC_DEF _cx_value* _cx_memb(_clone_range_p)(_cx_self* self, _cx_value* pos, const _cx_value* p1, const _cx_value* p2) { - pos = _cx_memb(_expand_uninit_p)(self, pos, p2 - p1); + pos = _cx_memb(_insert_uninit_p)(self, pos, p2 - p1); _cx_value* it = pos; if (pos) for (; p1 != p2; ++p1) *pos++ = i_keyclone((*p1)); @@ -387,7 +387,7 @@ _cx_memb(_clone_range_p)(_cx_self* self, _cx_value* pos, STC_DEF _cx_value* _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, const _cx_raw* p1, const _cx_raw* p2) { - pos = _cx_memb(_expand_uninit_p)(self, pos, p2 - p1); + pos = _cx_memb(_insert_uninit_p)(self, pos, p2 - p1); _cx_value* it = pos; if (pos) for (; p1 != p2; ++p1) *pos++ = i_keyfrom((*p1)); |
