From ac20f731153747ec5cbfc5566cc149485e20002a Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Sat, 15 May 2021 15:19:01 +0200 Subject: Renamed newly introduced internal c_cast() to c_make() for c++ compatability. Added usage. --- examples/advanced.c | 4 ++-- examples/random.c | 8 ++++---- examples/stc_astar.c | 2 +- stc/carray.h | 8 ++++---- stc/cbits.h | 56 ++++++++++++++++++++++++++-------------------------- stc/ccommon.h | 4 ++-- stc/cdeq.h | 8 ++++---- stc/clist.h | 8 ++++---- stc/cmap.h | 4 ++-- stc/crandom.h | 4 ++-- stc/csmap.h | 2 +- stc/cstr.h | 36 ++++++++++++++++++++------------- stc/cvec.h | 6 +++--- 13 files changed, 79 insertions(+), 71 deletions(-) diff --git a/examples/advanced.c b/examples/advanced.c index 73fcb470..b2dd1e57 100644 --- a/examples/advanced.c +++ b/examples/advanced.c @@ -28,10 +28,10 @@ static inline int vikingraw_equals(const VikingRaw* rx, const VikingRaw* ry) { } static inline Viking viking_fromRaw(VikingRaw raw) { // note: parameter is by value - Viking vk = {cstr_from(raw.name), cstr_from(raw.country)}; return vk; + return c_make(Viking){cstr_from(raw.name), cstr_from(raw.country)}; } static inline VikingRaw viking_toRaw(const Viking* vk) { - VikingRaw raw = {vk->name.str, vk->country.str}; return raw; + return c_make(VikingRaw){vk->name.str, vk->country.str}; } // With this in place, we use the using_cmap_keydef() macro to define {Viking -> int} hash map type: diff --git a/examples/random.c b/examples/random.c index 4fa1d487..32218b93 100644 --- a/examples/random.c +++ b/examples/random.c @@ -13,7 +13,7 @@ int main() uint64_t sum = 0; - stc64_normalf_t dist2 = stc64_normalf_init(R / 2.0, R / 6.0); + stc64_normalf_t dist2 = stc64_normalf_init((float)R / 2.0, (float)R / 6.0); size_t N2 = 10000000; int hist[R] = {0}; sum = 0; @@ -28,10 +28,10 @@ int main() printf("%3d %s\n", i, bar.str); } - clock_t diff, before; + clock_t diff, before; sum = 0; - before = clock(); + before = clock(); c_forrange (N) { sum += stc64_rand(&rng); } @@ -40,7 +40,7 @@ int main() stc64_uniform_t dist1 = stc64_uniform_init(0, 1000); sum = 0; - before = clock(); + before = clock(); c_forrange (N) { sum += stc64_uniform(&rng, &dist1); } diff --git a/examples/stc_astar.c b/examples/stc_astar.c index c22af8a8..90ef6e44 100644 --- a/examples/stc_astar.c +++ b/examples/stc_astar.c @@ -19,7 +19,7 @@ typedef struct { MazePoint mpnt_init(int x, int y, int width) { - MazePoint p = { x, y, 0, width }; return p; + return c_make(MazePoint){ x, y, 0, width }; } int diff --git a/stc/carray.h b/stc/carray.h index d61cbfcf..a8f02a95 100644 --- a/stc/carray.h +++ b/stc/carray.h @@ -84,10 +84,10 @@ int main() { } \ \ STC_INLINE CX##_iter_t CX##_begin(const CX* self) { \ - CX##_iter_t it = {*self->data}; return it; \ + return c_make(CX##_iter_t){*self->data}; \ } \ STC_INLINE CX##_iter_t CX##_end(const CX* self) { \ - CX##_iter_t it = {*self->data + self->xdim*self->ydim}; return it; \ + return c_make(CX##_iter_t){*self->data + self->xdim*self->ydim}; \ } \ STC_INLINE void CX##_next(CX##_iter_t* it) { ++it->ref; } \ \ @@ -131,10 +131,10 @@ int main() { } \ \ STC_INLINE CX##_iter_t CX##_begin(const CX* self) { \ - CX##_iter_t it = {**self->data}; return it; \ + return c_make(CX##_iter_t){**self->data}; \ } \ STC_INLINE CX##_iter_t CX##_end(const CX* self) { \ - CX##_iter_t it = {**self->data + CX##_size(*self)}; return it; \ + return c_make(CX##_iter_t){**self->data + CX##_size(*self)}; \ } \ STC_INLINE void CX##_next(CX##_iter_t* it) { ++it->ref; } \ \ diff --git a/stc/cbits.h b/stc/cbits.h index 4c708a7d..35f3f161 100644 --- a/stc/cbits.h +++ b/stc/cbits.h @@ -56,7 +56,7 @@ int main() { #include "ccommon.h" typedef struct { - uint64_t *at64; + uint64_t *data64; size_t size; } cbits; @@ -71,76 +71,76 @@ STC_API size_t cbits_count(cbits set); STC_API bool cbits_subset_of(cbits set, cbits other); STC_API bool cbits_disjoint(cbits set, cbits other); -STC_INLINE cbits cbits_init() { cbits set = {NULL, 0}; return set; } +STC_INLINE cbits cbits_init() { return c_make(cbits){NULL, 0}; } STC_INLINE void cbits_clear(cbits* self) { self->size = 0; } -STC_INLINE void cbits_del(cbits* self) { c_free(self->at64); } +STC_INLINE void cbits_del(cbits* self) { c_free(self->data64); } STC_INLINE size_t cbits_size(cbits set) { return set.size; } STC_INLINE cbits* cbits_take(cbits* self, cbits other) { - if (self->at64 != other.at64) {cbits_del(self); *self = other;} + if (self->data64 != other.data64) {cbits_del(self); *self = other;} return self; } STC_INLINE cbits cbits_move(cbits* self) { - cbits tmp = *self; self->at64 = NULL, self->size = 0; + cbits tmp = *self; self->data64 = NULL, self->size = 0; return tmp; } STC_INLINE bool cbits_test(cbits set, size_t i) { - return (set.at64[i >> 6] & (1ull << (i & 63))) != 0; + return (set.data64[i >> 6] & (1ull << (i & 63))) != 0; } STC_INLINE bool cbits_at(cbits set, size_t i) { - return (set.at64[i >> 6] & (1ull << (i & 63))) != 0; + return (set.data64[i >> 6] & (1ull << (i & 63))) != 0; } STC_INLINE void cbits_set(cbits *self, size_t i) { - self->at64[i >> 6] |= 1ull << (i & 63); + self->data64[i >> 6] |= 1ull << (i & 63); } STC_INLINE void cbits_reset(cbits *self, size_t i) { - self->at64[i >> 6] &= ~(1ull << (i & 63)); + self->data64[i >> 6] &= ~(1ull << (i & 63)); } STC_INLINE void cbits_set_value(cbits *self, size_t i, bool value) { - self->at64[i >> 6] ^= (-(uint64_t)value ^ self->at64[i >> 6]) & 1ull << (i & 63); + self->data64[i >> 6] ^= (-(uint64_t)value ^ self->data64[i >> 6]) & 1ull << (i & 63); } STC_INLINE void cbits_flip(cbits *self, size_t i) { - self->at64[i >> 6] ^= 1ull << (i & 63); + self->data64[i >> 6] ^= 1ull << (i & 63); } STC_INLINE void cbits_set_all(cbits *self, bool value) { - memset(self->at64, -(int)value, ((self->size + 63) >> 6) * 8); + memset(self->data64, -(int)value, ((self->size + 63) >> 6) * 8); } STC_INLINE void cbits_set_values(cbits *self, uint64_t pattern) { size_t n = (self->size + 63) >> 6; - for (size_t i=0; iat64[i] = pattern; + for (size_t i=0; idata64[i] = pattern; } STC_INLINE void cbits_flip_all(cbits *self) { size_t n = (self->size + 63) >> 6; - for (size_t i=0; iat64[i] ^= ~0ull; + for (size_t i=0; idata64[i] ^= ~0ull; } /* Intersection */ STC_INLINE void cbits_intersect(cbits *self, cbits other) { assert(self->size == other.size); size_t n = (self->size + 63) >> 6; - for (size_t i=0; iat64[i] &= other.at64[i]; + for (size_t i=0; idata64[i] &= other.data64[i]; } /* Union */ STC_INLINE void cbits_union(cbits *self, cbits other) { assert(self->size == other.size); size_t n = (self->size + 63) >> 6; - for (size_t i=0; iat64[i] |= other.at64[i]; + for (size_t i=0; idata64[i] |= other.data64[i]; } /* Exclusive disjunction */ STC_INLINE void cbits_xor(cbits *self, cbits other) { assert(self->size == other.size); size_t n = (self->size + 63) >> 6; - for (size_t i=0; iat64[i] ^= other.at64[i]; + for (size_t i=0; idata64[i] ^= other.data64[i]; } #if defined(__GNUC__) || defined(__clang__) @@ -160,21 +160,21 @@ STC_INLINE void cbits_xor(cbits *self, cbits other) { #if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) STC_DEF cbits* cbits_assign(cbits* self, cbits other) { - if (self->at64 == other.at64) return self; + if (self->data64 == other.data64) return self; if (self->size != other.size) return cbits_take(self, cbits_clone(other)); - memcpy(self->at64, other.at64, ((other.size + 63) >> 6)*8); + memcpy(self->data64, other.data64, ((other.size + 63) >> 6)*8); return self; } STC_DEF void cbits_resize(cbits* self, size_t size, bool value) { size_t new_n = (size + 63) >> 6, osize = self->size, old_n = (osize + 63) >> 6; - self->at64 = (uint64_t *) c_realloc(self->at64, new_n * 8); + self->data64 = (uint64_t *) c_realloc(self->data64, new_n * 8); self->size = size; if (new_n >= old_n) { - memset(self->at64 + old_n, -(int)value, (new_n - old_n) * 8); + memset(self->data64 + old_n, -(int)value, (new_n - old_n) * 8); if (old_n > 0) { uint64_t m = (1ull << (osize & 63)) - 1; /* mask */ - value ? (self->at64[old_n - 1] |= ~m) : (self->at64[old_n - 1] &= m); + value ? (self->data64[old_n - 1] |= ~m) : (self->data64[old_n - 1] &= m); } } } @@ -202,13 +202,13 @@ STC_DEF char* cbits_to_str(cbits set, char* out, size_t start, intptr_t stop) { } STC_DEF cbits cbits_clone(cbits other) { size_t bytes = ((other.size + 63) >> 6) * 8; - cbits set = {(uint64_t *) memcpy(c_malloc(bytes), other.at64, bytes), other.size}; + cbits set = {(uint64_t *) memcpy(c_malloc(bytes), other.data64, bytes), other.size}; return set; } STC_DEF size_t cbits_count(cbits s) { size_t count = 0, n = s.size >> 6; - for (size_t i = 0; i < n; ++i) count += cpopcount64(s.at64[i]); - if (s.size & 63) count += cpopcount64(s.at64[n] & ((1ull << (s.size & 63)) - 1)); + for (size_t i = 0; i < n; ++i) count += cpopcount64(s.data64[i]); + if (s.size & 63) count += cpopcount64(s.data64[n] & ((1ull << (s.size & 63)) - 1)); return count; } @@ -216,13 +216,13 @@ STC_DEF size_t cbits_count(cbits s) { assert(s.size == other.size); \ size_t n = s.size >> 6; \ for (size_t i = 0; i < n; ++i) \ - if ((s.at64[i] OPR other.at64[i]) != x) \ + if ((s.data64[i] OPR other.data64[i]) != x) \ return false; \ if (!(s.size & 63)) return true; \ uint64_t i = n, m = (1ull << (s.size & 63)) - 1; \ - return ((s.at64[i] OPR other.at64[i]) & m) == (x & m) + return ((s.data64[i] OPR other.data64[i]) & m) == (x & m) -STC_DEF bool cbits_subset_of(cbits s, cbits other) { _cbits_SETOP(|, s.at64[i]); } +STC_DEF bool cbits_subset_of(cbits s, cbits other) { _cbits_SETOP(|, s.data64[i]); } STC_DEF bool cbits_disjoint(cbits s, cbits other) { _cbits_SETOP(&, 0); } #endif diff --git a/stc/ccommon.h b/stc/ccommon.h index 38015d16..b3a1b766 100644 --- a/stc/ccommon.h +++ b/stc/ccommon.h @@ -69,11 +69,11 @@ #if __cplusplus #define c_new(T) static_cast(c_malloc(sizeof(T))) #define c_new_n(T, n) static_cast(c_malloc(sizeof(T)*(n))) -#define c_cast(T) T +#define c_make(T) T #else #define c_new(T) c_malloc(sizeof(T)) #define c_new_n(T, n) c_malloc(sizeof(T)*(n)) -#define c_cast(T) (T) +#define c_make(T) (T) #endif #ifndef c_malloc #define c_malloc(sz) malloc(sz) diff --git a/stc/cdeq.h b/stc/cdeq.h index d59af7d9..990c556a 100644 --- a/stc/cdeq.h +++ b/stc/cdeq.h @@ -91,9 +91,9 @@ struct cdeq_rep { size_t size, cap; void* base[]; }; STC_INLINE CX##_value_t* CX##_at(const CX* self, size_t idx) \ {assert(idx < _cdeq_rep(self)->size); return self->data + idx;} \ STC_INLINE CX##_iter_t CX##_begin(const CX* self) \ - {CX##_iter_t it = {self->data}; return it;} \ + {return c_make(CX##_iter_t){self->data};} \ STC_INLINE CX##_iter_t CX##_end(const CX* self) \ - {CX##_iter_t it = {self->data + _cdeq_rep(self)->size}; return it;} \ + {return c_make(CX##_iter_t){self->data + _cdeq_rep(self)->size};} \ STC_INLINE void CX##_next(CX##_iter_t* it) {++it->ref;} \ STC_INLINE CX##_iter_t CX##_adv(CX##_iter_t it, intptr_t offs) {it.ref += offs; return it;} \ STC_INLINE size_t CX##_idx(CX cx, CX##_iter_t it) {return it.ref - cx.data;} \ @@ -206,7 +206,7 @@ static struct cdeq_rep _cdeq_inits = {0, 0}; STC_DEF CX \ CX##_init(void) { \ CX##_value_t *b = (CX##_value_t *) _cdeq_inits.base; \ - CX cx = {b, b}; return cx; \ + return c_make(CX){b, b}; \ } \ \ STC_DEF void \ @@ -333,7 +333,7 @@ static struct cdeq_rep _cdeq_inits = {0, 0}; else memmove(p1, p2, (end - p2) * sizeof(Value)); \ _cdeq_rep(self)->size -= n; \ } \ - CX##_iter_t it = {p1}; return it; \ + return c_make(CX##_iter_t){p1}; \ } \ \ STC_DEF CX##_iter_t \ diff --git a/stc/clist.h b/stc/clist.h index ebdc7497..7a39081c 100644 --- a/stc/clist.h +++ b/stc/clist.h @@ -114,7 +114,7 @@ STC_API size_t _clist_count(const clist_VOID* self); STC_API CX##_iter_t CX##_find_in(CX##_iter_t it1, CX##_iter_t it2, RawValue val); \ STC_API CX##_node_t* CX##_erase_after_(CX* self, CX##_node_t* node); \ \ - STC_INLINE CX CX##_init(void) {CX cx = {NULL}; return cx;} \ + STC_INLINE CX CX##_init(void) {return c_make(CX){NULL};} \ STC_INLINE bool CX##_empty(CX cx) {return cx.last == NULL;} \ STC_INLINE size_t CX##_count(CX cx) \ {return _clist_count((const clist_VOID*) &cx);} \ @@ -138,18 +138,18 @@ STC_API size_t _clist_count(const clist_VOID* self); \ STC_INLINE CX##_iter_t \ CX##_iter(const CX* self, CX##_node_t* prev) { \ - CX##_iter_t it = {&self->last, prev, &prev->next->value}; return it; \ + return c_make(CX##_iter_t){&self->last, prev, &prev->next->value}; \ } \ \ STC_INLINE CX##_iter_t \ CX##_begin(const CX* self) { \ CX##_value_t* head = self->last ? &self->last->next->value : NULL; \ - CX##_iter_t it = {&self->last, self->last, head}; return it; \ + return c_make(CX##_iter_t){&self->last, self->last, head}; \ } \ \ STC_INLINE CX##_iter_t \ CX##_end(const CX* self) { \ - CX##_iter_t it = {NULL}; return it; \ + return c_make(CX##_iter_t){NULL}; \ } \ \ STC_INLINE void \ diff --git a/stc/cmap.h b/stc/cmap.h index 1258bb12..d9fd787c 100644 --- a/stc/cmap.h +++ b/stc/cmap.h @@ -190,7 +190,7 @@ STC_INLINE uint64_t c_default_hash64(const void* data, size_t ignored) STC_API CX##_result_t CX##_insert_entry_(CX* self, RawKey rkey); \ STC_API void CX##_erase_entry(CX* self, CX##_value_t* val); \ \ - STC_INLINE CX CX##_init(void) {CX m = _cmap_inits; return m;} \ + STC_INLINE CX CX##_init(void) {return c_make(CX)_cmap_inits;} \ STC_INLINE void CX##_shrink_to_fit(CX* self) {CX##_reserve(self, self->size);} \ STC_INLINE void CX##_max_load_factor(CX* self, float ml) {self->max_load_factor = ml;} \ STC_INLINE bool CX##_empty(CX m) {return m.size == 0;} \ @@ -288,7 +288,7 @@ STC_INLINE uint64_t c_default_hash64(const void* data, size_t ignored) \ STC_INLINE CX##_iter_t \ CX##_end(const CX* self) \ - {CX##_iter_t it = {self->table + self->bucket_count}; return it;} \ + {return c_make(CX##_iter_t){self->table + self->bucket_count};} \ \ STC_INLINE void \ CX##_next(CX##_iter_t* it) \ diff --git a/stc/crandom.h b/stc/crandom.h index 3dd9fe72..073048ee 100644 --- a/stc/crandom.h +++ b/stc/crandom.h @@ -77,7 +77,7 @@ STC_API stc64_uniform_t stc64_uniform_init(int64_t low, int64_t high); /* Float64 uniform distributed RNG, range [low, high). */ STC_INLINE stc64_uniformf_t stc64_uniformf_init(double low, double high) { - stc64_uniformf_t dist = {low, high - low}; return dist; + return c_make(stc64_uniformf_t){low, high - low}; } STC_INLINE double stc64_uniformf(stc64_t* rng, stc64_uniformf_t* dist) { return stc64_randf(rng)*dist->range + dist->lower; @@ -96,7 +96,7 @@ STC_INLINE int64_t stc64_uniform(stc64_t* rng, stc64_uniform_t* d) { /* Normal distributed RNG, Float64. */ STC_INLINE stc64_normalf_t stc64_normalf_init(double mean, double stddev) { - stc64_normalf_t dist = {mean, stddev, 0.0, 0}; return dist; + return c_make(stc64_normalf_t){mean, stddev, 0.0, 0}; } STC_API double stc64_normalf(stc64_t* rng, stc64_normalf_t* dist); diff --git a/stc/csmap.h b/stc/csmap.h index bea8abb4..60c3afc0 100644 --- a/stc/csmap.h +++ b/stc/csmap.h @@ -285,7 +285,7 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; }; \ STC_INLINE CX##_iter_t \ CX##_end(const CX* self) {\ - CX##_iter_t it; it.ref = NULL; return it; \ + return c_make(CX##_iter_t){.ref = NULL}; \ } \ \ _c_implement_aatree(CX, C, Key, Mapped, keyCompareRaw, \ diff --git a/stc/cstr.h b/stc/cstr.h index 890f6333..302bdfec 100644 --- a/stc/cstr.h +++ b/stc/cstr.h @@ -67,13 +67,13 @@ STC_API char* c_strncasestr(const char* s, const char* needle, size_t STC_INLINE cstr cstr_init() { return cstr_null; } #define cstr_new(literal) \ - cstr_from_n(literal, sizeof c_cast(strlit_t){literal} - 1) + cstr_from_n(literal, sizeof c_make(strlit_t){literal} - 1) STC_INLINE cstr cstr_from(const char* str) { return cstr_from_n(str, strlen(str)); } STC_INLINE size_t cstr_size(cstr s) { return _cstr_rep(&s)->size; } STC_INLINE size_t cstr_length(cstr s) { return _cstr_rep(&s)->size; } STC_INLINE size_t cstr_capacity(cstr s) { return _cstr_rep(&s)->cap; } -STC_INLINE size_t cstr_empty(cstr s) { return _cstr_rep(&s)->size == 0; } +STC_INLINE bool cstr_empty(cstr s) { return _cstr_rep(&s)->size == 0; } STC_INLINE void cstr_del(cstr* self) { if (_cstr_rep(self)->cap) c_free(_cstr_rep(self)); } STC_INLINE cstr cstr_clone(cstr s) @@ -108,9 +108,9 @@ STC_INLINE char* cstr_front(cstr* self) { return self->str; } STC_INLINE char* cstr_back(cstr* self) { return self->str + _cstr_rep(self)->size - 1; } STC_INLINE cstr_iter_t cstr_begin(cstr* self) - { return c_cast(cstr_iter_t){self->str}; } + { return c_make(cstr_iter_t){self->str}; } STC_INLINE cstr_iter_t cstr_end(cstr* self) - { return c_cast(cstr_iter_t){self->str + _cstr_rep(self)->size}; } + { return c_make(cstr_iter_t){self->str + _cstr_rep(self)->size}; } STC_INLINE void cstr_next(cstr_iter_t* it) {++it->ref; } STC_INLINE bool cstr_equals(cstr s1, const char* str) { return strcmp(s1.str, str) == 0; } @@ -122,10 +122,6 @@ STC_INLINE bool cstr_contains(cstr s, const char* needle) { return strstr(s.str, needle) != NULL; } STC_INLINE bool cstr_icontains(cstr s, const char* needle) { return c_strncasestr(s.str, needle, cstr_npos) != NULL; } -STC_INLINE bool cstr_begins_with(cstr s, const char* needle) - { return strncmp(s.str, needle, strlen(needle)) == 0; } -STC_INLINE bool cstr_ibegins_with(cstr s, const char* needle) - { return c_strncasecmp(s.str, needle, strlen(needle)) == 0; } STC_INLINE bool cstr_getline(cstr *self, FILE *stream) { return cstr_getdelim(self, '\n', stream); } @@ -159,15 +155,27 @@ cstr_move(cstr* self) { } STC_INLINE bool -cstr_ends_with(cstr s, const char* needle) { - size_t n = strlen(needle), sz = _cstr_rep(&s)->size; - return n <= sz ? memcmp(s.str + sz - n, needle, n) == 0 : false; +cstr_begins_with(cstr s, const char* sub) { + while (*sub && *s.str == *sub) ++s.str, ++sub; + return *sub == 0; } STC_INLINE bool -cstr_iends_with(cstr s, const char* needle) { - size_t n = strlen(needle), sz = _cstr_rep(&s)->size; - return n <= sz ? c_strncasecmp(s.str + sz - n, needle, n) == 0 : false; +cstr_ends_with(cstr s, const char* sub) { + size_t n = strlen(sub), sz = _cstr_rep(&s)->size; + return n <= sz ? memcmp(s.str + sz - n, sub, n) == 0 : false; +} + +STC_INLINE bool +cstr_ibegins_with(cstr s, const char* sub) { + while (*sub && tolower(*s.str) == tolower(*sub)) ++s.str, ++sub; + return *sub == 0; +} + +STC_INLINE bool +cstr_iends_with(cstr s, const char* sub) { + size_t n = strlen(sub), sz = _cstr_rep(&s)->size; + return n <= sz ? c_strncasecmp(s.str + sz - n, sub, n) == 0 : false; } /* cvec/cmap adaption functions: */ diff --git a/stc/cvec.h b/stc/cvec.h index 88422be4..dc090dae 100644 --- a/stc/cvec.h +++ b/stc/cvec.h @@ -86,9 +86,9 @@ struct cvec_rep { size_t size, cap; void* data[]; }; STC_INLINE Value CX##_value_clone(CX##_value_t val) \ {return valueFromRaw(valueToRaw(&val));} \ STC_INLINE CX##_iter_t CX##_begin(const CX* self) \ - {CX##_iter_t it = {self->data}; return it;} \ + {return c_make(CX##_iter_t){self->data};} \ STC_INLINE CX##_iter_t CX##_end(const CX* self) \ - {CX##_iter_t it = {self->data + _cvec_rep(self)->size}; return it;} \ + {return c_make(CX##_iter_t){self->data + _cvec_rep(self)->size};} \ STC_INLINE void CX##_next(CX##_iter_t* it) {++it->ref;} \ STC_INLINE CX##_iter_t CX##_adv(CX##_iter_t it, intptr_t offs) {it.ref += offs; return it;} \ STC_INLINE size_t CX##_idx(CX cx, CX##_iter_t it) {return it.ref - cx.data;} \ @@ -306,7 +306,7 @@ static struct cvec_rep _cvec_inits = {0, 0}; memmove(p1, p2, (end - p2) * sizeof(Value)); \ _cvec_rep(self)->size -= len; \ } \ - CX##_iter_t it = {p1}; return it; \ + return c_make(CX##_iter_t){.ref = p1}; \ } \ \ STC_DEF CX##_iter_t \ -- cgit v1.2.3