diff options
Diffstat (limited to 'misc/archived')
| -rw-r--r-- | misc/archived/carr2.h | 14 | ||||
| -rw-r--r-- | misc/archived/carr3.h | 14 | ||||
| -rw-r--r-- | misc/archived/csmap.h | 14 | ||||
| -rw-r--r-- | misc/archived/cstr.h | 12 |
4 files changed, 27 insertions, 27 deletions
diff --git a/misc/archived/carr2.h b/misc/archived/carr2.h index aebaec81..bff8a3b0 100644 --- a/misc/archived/carr2.h +++ b/misc/archived/carr2.h @@ -35,7 +35,7 @@ int main() { int w = 7, h = 5; - c_with (carr2_int image = carr2_int_new_uninit(w, h), carr2_int_drop(&image)) + c_WITH (carr2_int image = carr2_int_new_uninit(w, h), carr2_int_drop(&image)) { int *dat = carr2_int_data(&image); for (int i = 0; i < carr2_int_size(&image); ++i) @@ -46,7 +46,7 @@ int main() { printf(" %d", image.data[x][y]); puts("\n"); - c_foreach (i, carr2_int, image) + c_FOREACH (i, carr2_int, image) printf(" %d", *i.ref); puts(""); } @@ -71,7 +71,7 @@ STC_API void _cx_memb(_copy)(_cx_self *self, const _cx_self* other); #endif STC_INLINE _cx_self _cx_memb(_new_uninit)(size_t xdim, size_t ydim) { - return _cx_memb(_with_data)(xdim, ydim, c_alloc_n(_cx_value, xdim*ydim)); + return _cx_memb(_with_data)(xdim, ydim, c_ALLOC_N(_cx_value, xdim*ydim)); } STC_INLINE size_t _cx_memb(_size)(const _cx_self* self) { return self->xdim*self->ydim; } @@ -104,7 +104,7 @@ STC_INLINE void _cx_memb(_next)(_cx_iter* it) #if defined(i_implement) STC_DEF _cx_self _cx_memb(_with_data)(size_t xdim, size_t ydim, _cx_value* block) { - _cx_self _arr = {c_alloc_n(_cx_value*, xdim), xdim, ydim}; + _cx_self _arr = {c_ALLOC_N(_cx_value*, xdim), xdim, ydim}; for (size_t x = 0; x < xdim; ++x, block += ydim) _arr.data[x] = block; return _arr; @@ -134,7 +134,7 @@ STC_DEF void _cx_memb(_copy)(_cx_self *self, const _cx_self* other) { STC_DEF _cx_value *_cx_memb(_release)(_cx_self* self) { _cx_value *values = self->data[0]; - c_free(self->data); + c_FREE(self->data); self->data = NULL; return values; } @@ -144,8 +144,8 @@ STC_DEF void _cx_memb(_drop)(_cx_self* self) { for (_cx_value* p = self->data[0], *q = p + _cx_memb(_size)(self); p != q; ) { --q; i_keydrop(q); } - c_free(self->data[0]); /* values */ - c_free(self->data); /* pointers */ + c_FREE(self->data[0]); /* values */ + c_FREE(self->data); /* pointers */ } #endif diff --git a/misc/archived/carr3.h b/misc/archived/carr3.h index a0148992..e7e4c01f 100644 --- a/misc/archived/carr3.h +++ b/misc/archived/carr3.h @@ -35,7 +35,7 @@ int main() { int w = 7, h = 5, d = 3; - c_with (carr3_int image = carr3_int_new_uninit(w, h, d), carr3_int_drop(&image)) + c_WITH (carr3_int image = carr3_int_new_uninit(w, h, d), carr3_int_drop(&image)) { int *dat = carr3_int_data(&image); for (int i = 0; i < carr3_int_size(&image); ++i) @@ -47,7 +47,7 @@ int main() { printf(" %d", image.data[x][y][z]); puts("\n"); - c_foreach (i, carr3_int, image) + c_FOREACH (i, carr3_int, image) printf(" %d", *i.ref); puts(""); } @@ -73,7 +73,7 @@ STC_API void _cx_memb(_copy)(_cx_self *self, const _cx_self* other); #endif STC_INLINE _cx_self _cx_memb(_new_uninit)(size_t xdim, size_t ydim, size_t zdim) { - return _cx_memb(_with_data)(xdim, ydim, zdim, c_alloc_n(_cx_value, xdim*ydim*zdim)); + return _cx_memb(_with_data)(xdim, ydim, zdim, c_ALLOC_N(_cx_value, xdim*ydim*zdim)); } STC_INLINE size_t _cx_memb(_size)(const _cx_self* self) @@ -107,7 +107,7 @@ STC_INLINE void _cx_memb(_next)(_cx_iter* it) #if defined(i_implement) STC_DEF _cx_self _cx_memb(_with_data)(size_t xdim, size_t ydim, size_t zdim, _cx_value* block) { - _cx_self _arr = {c_alloc_n(_cx_value**, xdim*(ydim + 1)), xdim, ydim, zdim}; + _cx_self _arr = {c_ALLOC_N(_cx_value**, xdim*(ydim + 1)), xdim, ydim, zdim}; _cx_value** p = (_cx_value**) &_arr.data[xdim]; for (size_t x = 0, y; x < xdim; ++x, p += ydim) for (y = 0, _arr.data[x] = p; y < ydim; ++y, block += zdim) @@ -139,7 +139,7 @@ STC_DEF void _cx_memb(_copy)(_cx_self *self, const _cx_self* other) { STC_DEF _cx_value* _cx_memb(_release)(_cx_self* self) { _cx_value *values = self->data[0][0]; - c_free(self->data); + c_FREE(self->data); self->data = NULL; return values; } @@ -149,8 +149,8 @@ STC_DEF void _cx_memb(_drop)(_cx_self* self) { for (_cx_value* p = **self->data, *q = p + _cx_memb(_size)(self); p != q; ) { --q; i_keydrop(q); } - c_free(self->data[0][0]); /* data */ - c_free(self->data); /* pointers */ + c_FREE(self->data[0][0]); /* data */ + c_FREE(self->data); /* pointers */ } #endif diff --git a/misc/archived/csmap.h b/misc/archived/csmap.h index 4b4e764c..f035ff11 100644 --- a/misc/archived/csmap.h +++ b/misc/archived/csmap.h @@ -32,7 +32,7 @@ #include <stc/csmap.h> int main(void) { - c_with (csmap_sx m = csmap_sx_init(), csmap_sx_drop(&m)) + c_WITH (csmap_sx m = csmap_sx_init(), csmap_sx_drop(&m)) { csmap_sx_emplace(&m, "Testing one", 1.234); csmap_sx_emplace(&m, "Testing two", 12.34); @@ -43,7 +43,7 @@ int main(void) { csmap_sx_emplace_or_assign(&m, "Testing three", 1000.0); // update csmap_sx_erase(&m, "Testing two"); - c_foreach (i, csmap_sx, m) + c_FOREACH (i, csmap_sx, m) printf("map %s: %g\n", cstr_str(&i.ref->first), i.ref->second); } } @@ -113,7 +113,7 @@ STC_API void _cx_memb(_next)(_cx_iter* it); STC_INLINE bool _cx_memb(_empty)(_cx_self cx) { return cx.size == 0; } STC_INLINE size_t _cx_memb(_size)(_cx_self cx) { return cx.size; } -STC_INLINE void _cx_memb(_swap)(_cx_self* a, _cx_self* b) { c_swap(_cx_self, *a, *b); } +STC_INLINE void _cx_memb(_swap)(_cx_self* a, _cx_self* b) { c_SWAP(_cx_self, *a, *b); } STC_INLINE _cx_iter _cx_memb(_find)(const _cx_self* self, i_keyraw rkey) { _cx_iter it; _cx_memb(_find_it)(self, rkey, &it); return it; } STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, i_keyraw rkey) @@ -354,7 +354,7 @@ _cx_memb(_insert_entry_i_)(_cx_node* tn, const _cx_rawkey* rkey, _cx_result* res dir = (c < 0); tx = tx->link[dir]; } - tn = c_alloc(_cx_node); + tn = c_ALLOC(_cx_node); tn->link[0] = tn->link[1] = (_cx_node*)&_csmap_sentinel; tn->level = 1; res->ref = &tn->value, res->inserted = true; @@ -401,7 +401,7 @@ _cx_memb(_erase_r_)(_cx_node *tn, const _cx_rawkey* rkey, int *erased) { } else { /* unlink node */ tx = tn; tn = tn->link[tn->link[0]->level == 0]; - c_free(tx); + c_FREE(tx); } } if (tn->link[0]->level < tn->level - 1 || tn->link[1]->level < tn->level - 1) { @@ -461,7 +461,7 @@ static _cx_node* _cx_memb(_clone_r_)(_cx_node *tn) { if (! tn->level) return tn; - _cx_node *cn = c_alloc(_cx_node); + _cx_node *cn = c_ALLOC(_cx_node); cn->level = tn->level; cn->value = _cx_memb(_value_clone)(tn->value); cn->link[0] = _cx_memb(_clone_r_)(tn->link[0]); @@ -493,7 +493,7 @@ _cx_memb(_drop_r_)(_cx_node* tn) { _cx_memb(_drop_r_)(tn->link[0]); _cx_memb(_drop_r_)(tn->link[1]); _cx_memb(_value_drop)(&tn->value); - c_free(tn); + c_FREE(tn); } } diff --git a/misc/archived/cstr.h b/misc/archived/cstr.h index 8de6c4b0..45b11d78 100644 --- a/misc/archived/cstr.h +++ b/misc/archived/cstr.h @@ -77,7 +77,7 @@ STC_INLINE size_t cstr_size(const cstr* self) { return _cstr_p(self)->size STC_INLINE size_t cstr_capacity(cstr s) { return _cstr_p(&s)->cap; } STC_INLINE bool cstr_empty(cstr s) { return _cstr_p(&s)->size == 0; } STC_INLINE void cstr_drop(cstr* self) - { if (_cstr_p(self)->cap) c_free(_cstr_p(self)); } + { if (_cstr_p(self)->cap) c_FREE(_cstr_p(self)); } STC_INLINE cstr cstr_clone(cstr s) { return cstr_from_n(s.str, _cstr_p(&s)->size); } STC_INLINE void cstr_clear(cstr* self) @@ -142,7 +142,7 @@ STC_INLINE char* cstr_append_uninit(cstr *self, size_t n) { STC_INLINE cstr* cstr_take(cstr* self, cstr s) { if (self->str != s.str && _cstr_p(self)->cap) - c_free(_cstr_p(self)); + c_FREE(_cstr_p(self)); self->str = s.str; return self; } @@ -202,7 +202,7 @@ cstr_reserve(cstr* self, const size_t cap) { cstr_priv *p = _cstr_p(self); const size_t oldcap = p->cap; if (cap > oldcap) { - p = (cstr_priv*) c_realloc(((oldcap != 0) & (p != &_cstr_nullrep)) ? p : NULL, _cstr_opt_mem(cap)); + p = (cstr_priv*) c_REALLOC(((oldcap != 0) & (p != &_cstr_nullrep)) ? p : NULL, _cstr_opt_mem(cap)); if (!p) return NULL; self->str = p->chr; if (oldcap == 0) self->str[p->size = 0] = '\0'; @@ -222,7 +222,7 @@ cstr_resize(cstr* self, const size_t len, const char fill) { STC_DEF cstr cstr_from_n(const char* str, const size_t n) { if (n == 0) return cstr_NULL; - cstr_priv* prv = (cstr_priv*) c_malloc(_cstr_opt_mem(n)); + cstr_priv* prv = (cstr_priv*) c_MALLOC(_cstr_opt_mem(n)); cstr s = {(char *) memcpy(prv->chr, str, n)}; s.str[prv->size = n] = '\0'; prv->cap = _cstr_opt_cap(n); @@ -313,11 +313,11 @@ STC_DEF void cstr_replace_at_sv(cstr* self, const size_t pos, size_t len, csview repl) { const size_t sz = cstr_size(self); if (len > sz - pos) len = sz - pos; - char buf[256], *xstr = repl.size > 256 ? c_malloc(repl.size) : buf; + char buf[256], *xstr = repl.size > 256 ? c_MALLOC(repl.size) : buf; memcpy(xstr, repl.str, repl.size); _cstr_internal_move(self, pos + len, pos + repl.size); memcpy(&self->str[pos], xstr, repl.size); - if (repl.size > 256) c_free(xstr); + if (repl.size > 256) c_FREE(xstr); } STC_DEF cstr |
