summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--docs/ccommon_api.md4
-rw-r--r--include/stc/algo/filter.h24
-rw-r--r--include/stc/carc.h10
-rw-r--r--include/stc/cbits.h16
-rw-r--r--include/stc/cbox.h10
-rw-r--r--include/stc/ccommon.h104
-rw-r--r--include/stc/cdeq.h8
-rw-r--r--include/stc/clist.h16
-rw-r--r--include/stc/cmap.h26
-rw-r--r--include/stc/cpque.h4
-rw-r--r--include/stc/cqueue.h2
-rw-r--r--include/stc/cregex.h2
-rw-r--r--include/stc/cset.h2
-rw-r--r--include/stc/csmap.h10
-rw-r--r--include/stc/csset.h2
-rw-r--r--include/stc/cstack.h10
-rw-r--r--include/stc/cstr.h12
-rw-r--r--include/stc/csview.h6
-rw-r--r--include/stc/cvec.h6
-rw-r--r--include/stc/priv/lowcase.h (renamed from include/stc/priv/allcaps.h)67
-rw-r--r--misc/archived/carr2.h14
-rw-r--r--misc/archived/carr3.h14
-rw-r--r--misc/archived/csmap.h14
-rw-r--r--misc/archived/cstr.h12
-rw-r--r--misc/benchmarks/misc/cbits_benchmark.cpp12
-rw-r--r--misc/benchmarks/misc/string_bench_STC.cpp16
-rw-r--r--misc/benchmarks/picobench/picobench_cmap.cpp38
-rw-r--r--misc/benchmarks/picobench/picobench_csmap.cpp44
-rw-r--r--misc/benchmarks/plotbench/cdeq_benchmark.cpp38
-rw-r--r--misc/benchmarks/plotbench/clist_benchmark.cpp34
-rw-r--r--misc/benchmarks/plotbench/cmap_benchmark.cpp38
-rw-r--r--misc/benchmarks/plotbench/cpque_benchmark.cpp10
-rw-r--r--misc/benchmarks/plotbench/csmap_benchmark.cpp38
-rw-r--r--misc/benchmarks/plotbench/cvec_benchmark.cpp30
-rw-r--r--misc/benchmarks/shootout_hashmaps.cpp2
-rw-r--r--misc/examples/sidebyside.cpp4
-rw-r--r--src/checkauto.l42
-rw-r--r--src/cregex.c14
39 files changed, 372 insertions, 384 deletions
diff --git a/README.md b/README.md
index f3e0cfb5..475db445 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,7 @@ STC - Smart Template Containers for C
News: Version 4.1 Beta (Dec 2022)
------------------------------------------------
+- Major change is uppercase macros in ccommon.h. Lowercase macros are [still supported](include/stc/priv/lowcase.h).
- [See detailed changes for version 4](#version-4).
Introduction
diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md
index 474c80ac..d5ecc430 100644
--- a/docs/ccommon_api.md
+++ b/docs/ccommon_api.md
@@ -350,6 +350,6 @@ uint64_t crawstr_hash(const crawstr* x);
### c_MALLOC, c_CALLOC, c_REALLOC, c_FREE
Memory allocator for the entire library. Macros can be overloaded by the user.
-### c_swap, c_ARRAYLEN
-- **c_swap(type, x, y)**: Simple macro for swapping internals of two objects.
+### c_SWAP, c_ARRAYLEN
+- **c_SWAP(type, x, y)**: Simple macro for swapping internals of two objects.
- **c_ARRAYLEN(array)**: Return number of elements in an array, e.g. `int array[] = {1, 2, 3, 4};`
diff --git a/include/stc/algo/filter.h b/include/stc/algo/filter.h
index 10aeb7e7..74db5e04 100644
--- a/include/stc/algo/filter.h
+++ b/include/stc/algo/filter.h
@@ -37,9 +37,9 @@ int main()
puts("");
c_FORFILTER (i, cstack_int, stk
- , c_flt_skipwhile(i, *i.ref < 3)
+ , c_FLT_SKIPWHILE(i, *i.ref < 3)
&& (*i.ref & 1) == 0 // even only
- , c_flt_take(i, 2)) // break after 2
+ , c_FLT_TAKE(i, 2)) // break after 2
printf(" %d", *i.ref);
puts("");
}
@@ -54,20 +54,20 @@ int main()
#define c_NFILTERS 14 /* 22, 30, .. */
#endif
-#define c_flt_take(i, n) (++(i).s1[(i).s1top++] <= (n))
-#define c_flt_skip(i, n) (++(i).s1[(i).s1top++] > (n))
-#define c_flt_skipwhile(i, pred) ((i).s2[(i).s2top++] |= !(pred))
-#define c_flt_takewhile(i, pred) !c_flt_skipwhile(i, pred)
+#define c_FLT_TAKE(i, n) (++(i).s1[(i).s1top++] <= (n))
+#define c_FLT_SKIP(i, n) (++(i).s1[(i).s1top++] > (n))
+#define c_FLT_SKIPWHILE(i, pred) ((i).s2[(i).s2top++] |= !(pred))
+#define c_FLT_TAKEWHILE(i, pred) !c_FLT_SKIPWHILE(i, pred)
-#define c_forfilter(...) c_MACRO_OVERLOAD(c_forfilter, __VA_ARGS__)
+#define c_FORFILTER(...) c_MACRO_OVERLOAD(c_FORFILTER, __VA_ARGS__)
-#define c_forfilter4(i, C, cnt, filter) \
- c_forfilter_b(i, C, C##_begin(&cnt), filter)
+#define c_FORFILTER4(i, C, cnt, filter) \
+ c_FORFILTER_B(i, C, C##_begin(&cnt), filter)
-#define c_forfilter5(i, C, cnt, filter, cond) \
- c_forfilter_b(i, C, C##_begin(&cnt), filter) if (!(cond)) break; else
+#define c_FORFILTER5(i, C, cnt, filter, cond) \
+ c_FORFILTER_B(i, C, C##_begin(&cnt), filter) if (!(cond)) break; else
-#define c_forfilter_b(i, C, start, filter) \
+#define c_FORFILTER_B(i, C, start, filter) \
for (struct {C##_iter it; C##_value *ref; \
uint32_t s1[c_NFILTERS], index, count; \
bool s2[c_NFILTERS]; uint8_t s1top, s2top;} \
diff --git a/include/stc/carc.h b/include/stc/carc.h
index f14fdd65..130b90ef 100644
--- a/include/stc/carc.h
+++ b/include/stc/carc.h
@@ -45,7 +45,7 @@ int main() {
ArcPers q = ArcPers_clone(p); // share the pointer
printf("%s %s. uses: %ld\n", cstr_str(&q.get->name), cstr_str(&q.get->last), *q.use_count);
- c_drop(ArcPers, &p, &q);
+ c_DROP(ArcPers, &p, &q);
}
*/
#include "ccommon.h"
@@ -101,14 +101,14 @@ STC_INLINE long _cx_memb(_use_count)(const _cx_self* self)
STC_INLINE _cx_self _cx_memb(_from_ptr)(_cx_value* p) {
_cx_self ptr = {p};
if (p)
- *(ptr.use_count = c_alloc(catomic_long)) = 1;
+ *(ptr.use_count = c_ALLOC(catomic_long)) = 1;
return ptr;
}
// c++: std::make_shared<_cx_value>(val)
STC_INLINE _cx_self _cx_memb(_make)(_cx_value val) {
_cx_self ptr;
- struct _cx_memb(_rep_)* rep = c_alloc(struct _cx_memb(_rep_));
+ struct _cx_memb(_rep_)* rep = c_ALLOC(struct _cx_memb(_rep_));
*(ptr.use_count = &rep->counter) = 1;
*(ptr.get = &rep->value) = val;
return ptr;
@@ -127,8 +127,8 @@ STC_INLINE void _cx_memb(_drop)(_cx_self* self) {
if (self->use_count && _i_atomic_dec_and_test(self->use_count)) {
i_keydrop(self->get);
if ((char *)self->get != (char *)self->use_count + offsetof(struct _cx_memb(_rep_), value))
- c_free(self->get);
- c_free((long*)self->use_count);
+ c_FREE(self->get);
+ c_FREE((long*)self->use_count);
}
}
diff --git a/include/stc/cbits.h b/include/stc/cbits.h
index 3c187e78..fde1d05f 100644
--- a/include/stc/cbits.h
+++ b/include/stc/cbits.h
@@ -27,13 +27,13 @@ Similar to boost::dynamic_bitset / std::bitset
#include "cbits.h"
int main() {
- c_with (cbits bset = cbits_with_size(23, true), cbits_drop(&bset))
+ c_WITH (cbits bset = cbits_with_size(23, true), cbits_drop(&bset))
{
cbits_reset(&bset, 9);
cbits_resize(&bset, 43, false);
printf("%4zu: ", cbits_size(&bset));
- c_forrange (i, cbits_size(&bset))
+ c_FORRANGE (i, cbits_size(&bset))
printf("%d", cbits_at(&bset, i));
puts("");
cbits_set(&bset, 28);
@@ -43,7 +43,7 @@ int main() {
cbits_set_value(&bset, 99, false);
printf("%4zu: ", cbits_size(&bset));
- c_forrange (i, cbits_size(&bset))
+ c_FORRANGE (i, cbits_size(&bset))
printf("%d", cbits_at(&bset, i));
puts("");
}
@@ -125,7 +125,7 @@ struct { uint64_t *data64; size_t _size; } typedef i_type;
STC_INLINE cbits cbits_init(void) { return c_INIT(cbits){NULL}; }
STC_INLINE void cbits_create(cbits* self) { self->data64 = NULL; self->_size = 0; }
-STC_INLINE void cbits_drop(cbits* self) { c_free(self->data64); }
+STC_INLINE void cbits_drop(cbits* self) { c_FREE(self->data64); }
STC_INLINE size_t cbits_size(const cbits* self) { return self->_size; }
STC_INLINE cbits* cbits_take(cbits* self, cbits other) {
@@ -138,7 +138,7 @@ STC_INLINE cbits* cbits_take(cbits* self, cbits other) {
STC_INLINE cbits cbits_clone(cbits other) {
const size_t bytes = _cbits_bytes(other._size);
- cbits set = {(uint64_t *)memcpy(c_malloc(bytes), other.data64, bytes), other._size};
+ cbits set = {(uint64_t *)memcpy(c_MALLOC(bytes), other.data64, bytes), other._size};
return set;
}
@@ -153,7 +153,7 @@ STC_INLINE cbits* cbits_copy(cbits* self, const cbits* other) {
STC_INLINE void cbits_resize(cbits* self, const size_t size, const bool value) {
const size_t new_n = _cbits_words(size), osize = self->_size, old_n = _cbits_words(osize);
- self->data64 = (uint64_t *)c_realloc(self->data64, new_n*8);
+ self->data64 = (uint64_t *)c_REALLOC(self->data64, new_n*8);
self->_size = size;
if (new_n >= old_n) {
memset(self->data64 + old_n, -(int)value, (new_n - old_n)*8);
@@ -175,13 +175,13 @@ STC_INLINE cbits cbits_move(cbits* self) {
}
STC_INLINE cbits cbits_with_size(const size_t size, const bool value) {
- cbits set = {(uint64_t *)c_malloc(_cbits_bytes(size)), size};
+ cbits set = {(uint64_t *)c_MALLOC(_cbits_bytes(size)), size};
cbits_set_all(&set, value);
return set;
}
STC_INLINE cbits cbits_with_pattern(const size_t size, const uint64_t pattern) {
- cbits set = {(uint64_t *)c_malloc(_cbits_bytes(size)), size};
+ cbits set = {(uint64_t *)c_MALLOC(_cbits_bytes(size)), size};
cbits_set_pattern(&set, pattern);
return set;
}
diff --git a/include/stc/cbox.h b/include/stc/cbox.h
index b8a61375..7be3dc36 100644
--- a/include/stc/cbox.h
+++ b/include/stc/cbox.h
@@ -37,7 +37,7 @@ Person Person_clone(Person p) {
}
void Person_drop(Person* p) {
printf("drop: %s %s\n", cstr_str(&p->name), cstr_str(&p->email));
- c_drop(cstr, &p->name, &p->email);
+ c_DROP(cstr, &p->name, &p->email);
}
#define i_keyclass Person // bind Person clone+drop fn's
@@ -45,7 +45,7 @@ void Person_drop(Person* p) {
#include <stc/cbox.h>
int main() {
- c_auto (PBox, p, q)
+ c_AUTO (PBox, p, q)
{
p = PBox_from(Person_from("John Smiths", "[email protected]"));
q = PBox_clone(p);
@@ -89,7 +89,7 @@ STC_INLINE _cx_self _cx_memb(_from_ptr)(_cx_value* p)
// c++: std::make_unique<i_key>(val)
STC_INLINE _cx_self _cx_memb(_make)(_cx_value val) {
- _cx_self ptr = {c_alloc(_cx_value)};
+ _cx_self ptr = {c_ALLOC(_cx_value)};
*ptr.get = val; return ptr;
}
@@ -100,7 +100,7 @@ STC_INLINE _cx_raw _cx_memb(_toraw)(const _cx_self* self)
STC_INLINE void _cx_memb(_drop)(_cx_self* self) {
if (self->get) {
i_keydrop(self->get);
- c_free(self->get);
+ c_FREE(self->get);
}
}
@@ -136,7 +136,7 @@ STC_INLINE _cx_self _cx_memb(_from)(_cx_value val)
STC_INLINE _cx_self _cx_memb(_clone)(_cx_self other) {
if (!other.get)
return other;
- _cx_self out = {c_alloc(i_key)};
+ _cx_self out = {c_ALLOC(i_key)};
*out.get = i_keyclone(*other.get);
return out;
}
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 95c35915..ce6bba84 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -29,7 +29,7 @@
#include <stdbool.h>
#include <string.h>
#include <assert.h>
-#include "priv/allcaps.h"
+#include "priv/lowcase.h"
#if SIZE_MAX == UINT32_MAX
#define c_ZU PRIu32
@@ -62,33 +62,33 @@
#define _c_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, \
_14, _15, _16, N, ...) N
-#define c_static_assert(cond) \
+#define c_STATIC_ASSERT(cond) \
typedef char c_PASTE(_static_assert_line_, __LINE__)[(cond) ? 1 : -1]
-#define c_container_of(p, T, m) \
+#define c_CONTAINER_OF(p, T, m) \
((T*)((char*)(p) + 0*sizeof((p) == &((T*)0)->m) - offsetof(T, m)))
#ifndef __cplusplus
- #define c_alloc(T) c_malloc(sizeof(T))
- #define c_alloc_n(T, n) c_malloc(sizeof(T)*(n))
- #define c_new(T, ...) ((T*)memcpy(c_alloc(T), (T[]){__VA_ARGS__}, sizeof(T)))
+ #define c_ALLOC(T) c_MALLOC(sizeof(T))
+ #define c_ALLOC_N(T, n) c_MALLOC(sizeof(T)*(n))
+ #define c_NEW(T, ...) ((T*)memcpy(c_ALLOC(T), (T[]){__VA_ARGS__}, sizeof(T)))
#define c_INIT(T) (T)
#else
#include <new>
- #define c_alloc(T) static_cast<T*>(c_malloc(sizeof(T)))
- #define c_alloc_n(T, n) static_cast<T*>(c_malloc(sizeof(T)*(n)))
- #define c_new(T, ...) new (c_alloc(T)) T(__VA_ARGS__)
+ #define c_ALLOC(T) static_cast<T*>(c_MALLOC(sizeof(T)))
+ #define c_ALLOC_N(T, n) static_cast<T*>(c_MALLOC(sizeof(T)*(n)))
+ #define c_NEW(T, ...) new (c_ALLOC(T)) T(__VA_ARGS__)
#define c_INIT(T) T
#endif
-#ifndef c_malloc
- #define c_malloc(sz) malloc(sz)
- #define c_calloc(n, sz) calloc(n, sz)
- #define c_realloc(p, sz) realloc(p, sz)
- #define c_free(p) free(p)
+#ifndef c_MALLOC
+ #define c_MALLOC(sz) malloc(sz)
+ #define c_CALLOC(n, sz) calloc(n, sz)
+ #define c_REALLOC(p, sz) realloc(p, sz)
+ #define c_FREE(p) free(p)
#endif
-#define c_delete(T, ptr) do { T *_c_p = ptr; T##_drop(_c_p); c_free(_c_p); } while (0)
-#define c_swap(T, x, y) do { T _c_t = x; x = y; y = _c_t; } while (0)
-#define c_arraylen(a) (sizeof (a)/sizeof *(a))
+#define c_DELETE(T, ptr) do { T *_c_p = ptr; T##_drop(_c_p); c_FREE(_c_p); } while (0)
+#define c_SWAP(T, x, y) do { T _c_t = x; x = y; y = _c_t; } while (0)
+#define c_ARRAYLEN(a) (sizeof (a)/sizeof *(a))
// x and y are i_keyraw* type, defaults to i_key*:
#define c_default_cmp(x, y) (c_default_less(y, x) - c_default_less(x, y))
@@ -162,72 +162,72 @@ STC_INLINE char* cstrnstrn(const char *str, const char *needle,
return NULL;
}
-#define c_foreach(...) c_MACRO_OVERLOAD(c_foreach, __VA_ARGS__)
-#define c_foreach3(it, C, cnt) \
+#define c_FOREACH(...) c_MACRO_OVERLOAD(c_FOREACH, __VA_ARGS__)
+#define c_FOREACH3(it, C, cnt) \
for (C##_iter it = C##_begin(&cnt); it.ref; C##_next(&it))
-#define c_foreach4(it, C, start, finish) \
+#define c_FOREACH4(it, C, start, finish) \
for (C##_iter it = start, *_endref = (C##_iter*)(finish).ref \
; it.ref != (C##_value*)_endref; C##_next(&it))
-#define c_forwhile(i, C, start, cond) \
+#define c_FORWHILE(i, C, start, cond) \
for (struct {C##_iter it; C##_value *ref; size_t index;} \
i = {.it=start, .ref=i.it.ref}; i.it.ref && (cond) \
; C##_next(&i.it), i.ref = i.it.ref, ++i.index)
-#define c_forpair(key, val, C, cnt) /* structured binding */ \
+#define c_FORPAIR(key, val, C, cnt) /* structured binding */ \
for (struct {C##_iter it; const C##_key* key; C##_mapped* val;} _ = {.it=C##_begin(&cnt)} \
; _.it.ref && (_.key = &_.it.ref->first, _.val = &_.it.ref->second) \
; C##_next(&_.it))
-#define c_forrange(...) c_MACRO_OVERLOAD(c_forrange, __VA_ARGS__)
-#define c_forrange1(stop) c_forrange3(_c_i, 0, stop)
-#define c_forrange2(i, stop) c_forrange3(i, 0, stop)
-#define c_forrange3(i, start, stop) \
+#define c_FORRANGE(...) c_MACRO_OVERLOAD(c_FORRANGE, __VA_ARGS__)
+#define c_FORRANGE1(stop) c_FORRANGE3(_c_i, 0, stop)
+#define c_FORRANGE2(i, stop) c_FORRANGE3(i, 0, stop)
+#define c_FORRANGE3(i, start, stop) \
for (long long i=start, _end=(long long)(stop); i < _end; ++i)
-#define c_forrange4(i, start, stop, step) \
+#define c_FORRANGE4(i, start, stop, step) \
for (long long i=start, _inc=step, _end=(long long)(stop) - (_inc > 0) \
; (_inc > 0) ^ (i > _end); i += _inc)
#ifndef __cplusplus
- #define c_forlist(it, T, ...) \
+ #define c_FORLIST(it, T, ...) \
for (struct {T* data; T* ref; int size, index;} \
it = {.data=(T[])__VA_ARGS__, .ref=it.data, .size=sizeof((T[])__VA_ARGS__)/sizeof(T)} \
; it.index < it.size; ++it.ref, ++it.index)
#else
#include <initializer_list>
- #define c_forlist(it, T, ...) \
+ #define c_FORLIST(it, T, ...) \
for (struct {std::initializer_list<T> _il; std::initializer_list<T>::iterator data, ref; size_t size, index;} \
it = {._il=__VA_ARGS__, .data=it._il.begin(), .ref=it.data, .size=it._il.size()} \
; it.index < it.size; ++it.ref, ++it.index)
#endif
-#define c_with(...) c_MACRO_OVERLOAD(c_with, __VA_ARGS__)
-#define c_with2(declvar, drop) for (declvar, **_c_i = NULL; !_c_i; ++_c_i, drop)
-#define c_with3(declvar, pred, drop) for (declvar, **_c_i = NULL; !_c_i && (pred); ++_c_i, drop)
-#define c_scope(init, drop) for (int _c_i = (init, 0); !_c_i; ++_c_i, drop)
-#define c_defer(...) for (int _c_i = 0; !_c_i; ++_c_i, __VA_ARGS__)
-#define c_autodrop(C, a, ...) for (C a = __VA_ARGS__, **_c_i = NULL; !_c_i; ++_c_i, C##_drop(&a))
+#define c_WITH(...) c_MACRO_OVERLOAD(c_WITH, __VA_ARGS__)
+#define c_WITH2(declvar, drop) for (declvar, **_c_i = NULL; !_c_i; ++_c_i, drop)
+#define c_WITH3(declvar, pred, drop) for (declvar, **_c_i = NULL; !_c_i && (pred); ++_c_i, drop)
+#define c_SCOPE(init, drop) for (int _c_i = (init, 0); !_c_i; ++_c_i, drop)
+#define c_DEFER(...) for (int _c_i = 0; !_c_i; ++_c_i, __VA_ARGS__)
+#define c_AUTODROP(C, a, ...) for (C a = __VA_ARGS__, **_c_i = NULL; !_c_i; ++_c_i, C##_drop(&a))
-#define c_auto(...) c_MACRO_OVERLOAD(c_auto, __VA_ARGS__)
-#define c_auto2(C, a) \
- c_with2(C a = C##_init(), C##_drop(&a))
-#define c_auto3(C, a, b) \
- c_with2(c_EXPAND(C a = C##_init(), b = C##_init()), \
- (C##_drop(&b), C##_drop(&a)))
-#define c_auto4(C, a, b, c) \
- c_with2(c_EXPAND(C a = C##_init(), b = C##_init(), c = C##_init()), \
- (C##_drop(&c), C##_drop(&b), C##_drop(&a)))
-#define c_auto5(C, a, b, c, d) \
- c_with2(c_EXPAND(C a = C##_init(), b = C##_init(), c = C##_init(), d = C##_init()), \
- (C##_drop(&d), C##_drop(&c), C##_drop(&b), C##_drop(&a)))
+#define c_AUTO(...) c_MACRO_OVERLOAD(c_AUTO, __VA_ARGS__)
+#define c_AUTO2(C, a) \
+ c_WITH2(C a = C##_init(), C##_drop(&a))
+#define c_AUTO3(C, a, b) \
+ c_WITH2(c_EXPAND(C a = C##_init(), b = C##_init()), \
+ (C##_drop(&b), C##_drop(&a)))
+#define c_AUTO4(C, a, b, c) \
+ c_WITH2(c_EXPAND(C a = C##_init(), b = C##_init(), c = C##_init()), \
+ (C##_drop(&c), C##_drop(&b), C##_drop(&a)))
+#define c_AUTO5(C, a, b, c, d) \
+ c_WITH2(c_EXPAND(C a = C##_init(), b = C##_init(), c = C##_init(), d = C##_init()), \
+ (C##_drop(&d), C##_drop(&c), C##_drop(&b), C##_drop(&a)))
-#define c_drop(C, ...) do { c_forlist (_i, C*, {__VA_ARGS__}) C##_drop(*_i.ref); } while(0)
+#define c_DROP(C, ...) do { c_FORLIST (_i, C*, {__VA_ARGS__}) C##_drop(*_i.ref); } while(0)
-#define c_find_if(...) c_MACRO_OVERLOAD(c_find_if, __VA_ARGS__)
-#define c_find_if4(it, C, cnt, pred) do { \
+#define c_FIND_IF(...) c_MACRO_OVERLOAD(c_FIND_IF, __VA_ARGS__)
+#define c_FIND_IF4(it, C, cnt, pred) do { \
size_t index = 0; \
for (it = C##_begin(&cnt); it.ref && !(pred); C##_next(&it)) \
++index; \
} while (0)
-#define c_find_if5(it, C, start, end, pred) do { \
+#define c_FIND_IF5(it, C, start, end, pred) do { \
size_t index = 0; \
const C##_value* _endref = (end).ref; \
for (it = start; it.ref != _endref && !(pred); C##_next(&it)) \
@@ -235,7 +235,7 @@ STC_INLINE char* cstrnstrn(const char *str, const char *needle,
if (it.ref == _endref) it.ref = NULL; \
} while (0)
-#define c_erase_if(it, C, cnt, pred) do { \
+#define c_ERASE_IF(it, C, cnt, pred) do { \
C##_iter it = C##_begin(&cnt); \
for (size_t index = 0; it.ref; ++index) { \
if (pred) it = C##_erase_at(&cnt, it); \
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h
index 9416d5b2..d9205e61 100644
--- a/include/stc/cdeq.h
+++ b/include/stc/cdeq.h
@@ -90,7 +90,7 @@ STC_INLINE size_t _cx_memb(_size)(const _cx_self* self) { return self->_le
STC_INLINE size_t _cx_memb(_capacity)(const _cx_self* self) { return self->_cap; }
STC_INLINE bool _cx_memb(_empty)(const _cx_self* self) { return !self->_len; }
STC_INLINE _cx_raw _cx_memb(_value_toraw)(const _cx_value* pval) { return i_keyto(pval); }
-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_value* _cx_memb(_front)(const _cx_self* self) { return self->data; }
STC_INLINE _cx_value* _cx_memb(_back)(const _cx_self* self)
{ return self->data + self->_len - 1; }
@@ -227,7 +227,7 @@ STC_DEF void
_cx_memb(_shrink_to_fit)(_cx_self *self) {
if (self->_len != self->_cap) {
memmove(self->_base, self->data, self->_len*sizeof(i_key));
- _cx_value* d = (_cx_value*)c_realloc(self->_base, self->_len*sizeof(i_key));
+ _cx_value* d = (_cx_value*)c_REALLOC(self->_base, self->_len*sizeof(i_key));
if (d) {
self->_base = d;
self->_cap = self->_len;
@@ -240,7 +240,7 @@ STC_DEF void
_cx_memb(_drop)(_cx_self* self) {
if (self->_base) {
_cx_memb(_clear)(self);
- c_free(self->_base);
+ c_FREE(self->_base);
}
}
@@ -248,7 +248,7 @@ static size_t
_cx_memb(_realloc_)(_cx_self* self, const size_t n) {
const size_t cap = (size_t)((float)self->_len*1.7f) + n + 7U;
const size_t nfront = _cdeq_nfront(self);
- _cx_value* d = (_cx_value*)c_realloc(self->_base, cap*sizeof(i_key));
+ _cx_value* d = (_cx_value*)c_REALLOC(self->_base, cap*sizeof(i_key));
if (!d)
return 0;
self->_cap = cap;
diff --git a/include/stc/clist.h b/include/stc/clist.h
index 1ace1dac..89f3533e 100644
--- a/include/stc/clist.h
+++ b/include/stc/clist.h
@@ -34,19 +34,19 @@
int main()
{
- c_auto (clist_ix, list)
+ c_AUTO (clist_ix, list)
{
int n;
for (int i = 0; i < 1000000; ++i) // one million
clist_ix_push_back(&list, crandom() >> 32);
n = 0;
- c_foreach (i, clist_ix, list)
+ c_FOREACH (i, clist_ix, list)
if (++n % 10000 == 0) printf("%8d: %10zu\n", n, *i.ref);
// Sort them...
clist_ix_sort(&list); // mergesort O(n*log n)
n = 0;
puts("sorted");
- c_foreach (i, clist_ix, list)
+ c_FOREACH (i, clist_ix, list)
if (++n % 10000 == 0) printf("%8d: %10zu\n", n, *i.ref);
}
}
@@ -64,13 +64,13 @@
SELF##_value value; \
}
-#define _clist_tonode(vp) c_container_of(vp, _cx_node, value)
+#define _clist_tonode(vp) c_CONTAINER_OF(vp, _cx_node, value)
_c_clist_types(clist_VOID, int);
_c_clist_complete_types(clist_VOID, dummy);
#define _c_clist_insert_entry_after(ref, val) \
- _cx_node *entry = c_alloc(_cx_node); entry->value = val; \
+ _cx_node *entry = c_ALLOC(_cx_node); entry->value = val; \
_c_clist_insert_node_after(ref, entry)
#define _c_clist_insert_node_after(ref, entry) \
@@ -269,7 +269,7 @@ _clist_mergesort(clist_VOID_node *list, int (*cmp)(const clist_VOID_node*, const
STC_DEF _cx_self
_cx_memb(_clone)(_cx_self cx) {
_cx_self out = _cx_memb(_init)();
- c_foreach (it, _cx_self, cx)
+ c_FOREACH (it, _cx_self, cx)
_cx_memb(_push_back)(&out, i_keyclone((*it.ref)));
return out;
}
@@ -344,7 +344,7 @@ STC_DEF void
_cx_memb(_erase_node_after)(_cx_self* self, _cx_node* ref) {
_cx_node* node = _cx_memb(_unlink_node_after)(self, ref);
i_keydrop((&node->value));
- c_free(node);
+ c_FREE(node);
}
STC_DEF _cx_node*
@@ -402,7 +402,7 @@ _cx_memb(_split_off)(_cx_self* self, _cx_iter it1, _cx_iter it2) {
STC_DEF _cx_iter
_cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, _cx_raw val) {
- c_foreach (it, _cx_self, it1, it2) {
+ c_FOREACH (it, _cx_self, it1, it2) {
_cx_raw r = i_keyto(it.ref);
if (i_eq((&r), (&val)))
return it;
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index 11edf127..1d0583f4 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -31,7 +31,7 @@
#include <stc/cmap.h>
int main(void) {
- c_with (cmap_ichar m = cmap_ichar_init(), cmap_ichar_drop(&m))
+ c_WITH (cmap_ichar m = cmap_ichar_init(), cmap_ichar_drop(&m))
{
cmap_ichar_emplace(&m, 5, 'a');
cmap_ichar_emplace(&m, 8, 'b');
@@ -42,7 +42,7 @@ int main(void) {
cmap_ichar_emplace_or_assign(&m, 5, 'd'); // update
cmap_ichar_erase(&m, 8);
- c_foreach (i, cmap_ichar, m)
+ c_FOREACH (i, cmap_ichar, m)
printf("map %d: %c\n", i.ref->first, i.ref->second);
}
}
@@ -115,7 +115,7 @@ STC_INLINE size_t _cx_memb(_size)(const _cx_self* map) { return map->size;
STC_INLINE size_t _cx_memb(_bucket_count)(_cx_self* map) { return map->bucket_count; }
STC_INLINE size_t _cx_memb(_capacity)(const _cx_self* map)
{ return (size_t)((float)map->bucket_count * (i_max_load_factor)); }
-STC_INLINE void _cx_memb(_swap)(_cx_self *map1, _cx_self *map2) {c_swap(_cx_self, *map1, *map2); }
+STC_INLINE void _cx_memb(_swap)(_cx_self *map1, _cx_self *map2) {c_SWAP(_cx_self, *map1, *map2); }
STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, _cx_rawkey rkey)
{ return self->size && self->_hashx[_cx_memb(_bucket_)(self, &rkey).idx]; }
@@ -298,8 +298,8 @@ STC_INLINE void _cx_memb(_wipe_)(_cx_self* self) {
STC_DEF void _cx_memb(_drop)(_cx_self* self) {
_cx_memb(_wipe_)(self);
- c_free(self->_hashx);
- c_free((void *) self->table);
+ c_FREE(self->_hashx);
+ c_FREE((void *) self->table);
}
STC_DEF void _cx_memb(_clear)(_cx_self* self) {
@@ -370,10 +370,10 @@ _cx_memb(_insert_entry_)(_cx_self* self, _cx_rawkey rkey) {
STC_DEF _cx_self
_cx_memb(_clone)(_cx_self m) {
if (m.table) {
- _cx_value *t = c_alloc_n(_cx_value, m.bucket_count), *dst = t, *m_end = m.table + m.bucket_count;
- uint8_t *h = (uint8_t *)memcpy(c_malloc(m.bucket_count + 1), m._hashx, m.bucket_count + 1);
+ _cx_value *t = c_ALLOC_N(_cx_value, m.bucket_count), *dst = t, *m_end = m.table + m.bucket_count;
+ uint8_t *h = (uint8_t *)memcpy(c_MALLOC(m.bucket_count + 1), m._hashx, m.bucket_count + 1);
if (!(t && h))
- { c_free(t), c_free(h), t = 0, h = 0, m.bucket_count = 0; }
+ { c_FREE(t), c_FREE(h), t = 0, h = 0, m.bucket_count = 0; }
else
for (; m.table != m_end; ++m.table, ++m._hashx, ++dst)
if (*m._hashx)
@@ -396,8 +396,8 @@ _cx_memb(_reserve)(_cx_self* self, const size_t _newcap) {
_nbuckets |= 1;
#endif
_cx_self m = {
- c_alloc_n(_cx_value, _nbuckets),
- (uint8_t *) c_calloc(_nbuckets + 1, 1),
+ c_ALLOC_N(_cx_value, _nbuckets),
+ (uint8_t *) c_CALLOC(_nbuckets + 1, 1),
self->size, (i_size)_nbuckets,
};
bool ok = m.table && m._hashx;
@@ -411,10 +411,10 @@ _cx_memb(_reserve)(_cx_self* self, const size_t _newcap) {
m.table[b.idx] = *e;
m._hashx[b.idx] = (uint8_t)b.hx;
}
- c_swap(_cx_self, *self, m);
+ c_SWAP(_cx_self, *self, m);
}
- c_free(m._hashx);
- c_free(m.table);
+ c_FREE(m._hashx);
+ c_FREE(m.table);
return ok;
}
diff --git a/include/stc/cpque.h b/include/stc/cpque.h
index c1e7c13b..7f4bb588 100644
--- a/include/stc/cpque.h
+++ b/include/stc/cpque.h
@@ -49,7 +49,7 @@ STC_INLINE _cx_self _cx_memb(_init)(void)
STC_INLINE bool _cx_memb(_reserve)(_cx_self* self, const size_t cap) {
if (cap != self->_len && cap <= self->_cap) return true;
- _cx_value *d = (_cx_value *)c_realloc(self->data, cap*sizeof *d);
+ _cx_value *d = (_cx_value *)c_REALLOC(self->data, cap*sizeof *d);
return d ? (self->data = d, self->_cap = cap, true) : false;
}
@@ -73,7 +73,7 @@ STC_INLINE void _cx_memb(_clear)(_cx_self* self) {
}
STC_INLINE void _cx_memb(_drop)(_cx_self* self)
- { _cx_memb(_clear)(self); c_free(self->data); }
+ { _cx_memb(_clear)(self); c_FREE(self->data); }
STC_INLINE size_t _cx_memb(_size)(const _cx_self* q)
{ return q->_len; }
diff --git a/include/stc/cqueue.h b/include/stc/cqueue.h
index 0c0df063..319b5b47 100644
--- a/include/stc/cqueue.h
+++ b/include/stc/cqueue.h
@@ -33,7 +33,7 @@ int main() {
stc64_t rng = stc64_new(1234);
stc64_uniform_t dist = stc64_uniform_new(0, n);
- c_auto (cqueue_int, Q)
+ c_AUTO (cqueue_int, Q)
{
// Push ten million random numbers onto the queue.
for (int i=0; i<n; ++i)
diff --git a/include/stc/cregex.h b/include/stc/cregex.h
index 975bd675..4bb17938 100644
--- a/include/stc/cregex.h
+++ b/include/stc/cregex.h
@@ -79,7 +79,7 @@ typedef struct {
csview match[CREG_MAX_CAPTURES];
} cregex_iter;
-#define c_formatch(it, Re, Input) \
+#define c_FORMATCH(it, Re, Input) \
for (cregex_iter it = {Re, Input}; \
cregex_find(it.re, it.input, it.match, CREG_M_NEXT) == CREG_OK; )
diff --git a/include/stc/cset.h b/include/stc/cset.h
index 0dddc02f..cc3aa1e4 100644
--- a/include/stc/cset.h
+++ b/include/stc/cset.h
@@ -33,7 +33,7 @@ int main(void) {
cset_sx_insert(&s, 5);
cset_sx_insert(&s, 8);
- c_foreach (i, cset_sx, s)
+ c_FOREACH (i, cset_sx, s)
printf("set %d\n", *i.ref);
cset_sx_drop(&s);
}
diff --git a/include/stc/csmap.h b/include/stc/csmap.h
index f651db00..e3b82fea 100644
--- a/include/stc/csmap.h
+++ b/include/stc/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);
}
}
@@ -120,7 +120,7 @@ STC_API void _cx_memb(_next)(_cx_iter* it);
STC_INLINE bool _cx_memb(_empty)(const _cx_self* cx) { return cx->size == 0; }
STC_INLINE size_t _cx_memb(_size)(const _cx_self* cx) { return cx->size; }
STC_INLINE size_t _cx_memb(_capacity)(const _cx_self* cx) { return cx->cap; }
-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, _cx_rawkey rkey)
{ _cx_iter it; _cx_memb(_find_it)(self, rkey, &it); return it; }
STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, _cx_rawkey rkey)
@@ -229,7 +229,7 @@ STC_DEF bool
_cx_memb(_reserve)(_cx_self* self, const size_t cap) {
if (cap <= self->cap)
return false;
- _cx_node* nodes = (_cx_node*)c_realloc(self->nodes, (cap + 1)*sizeof(_cx_node));
+ _cx_node* nodes = (_cx_node*)c_REALLOC(self->nodes, (cap + 1)*sizeof(_cx_node));
if (!nodes)
return false;
nodes[0] = c_INIT(_cx_node){{0, 0}, 0};
@@ -563,7 +563,7 @@ STC_DEF void
_cx_memb(_drop)(_cx_self* self) {
if (self->cap) {
_cx_memb(_drop_r_)(self->nodes, self->root);
- c_free(self->nodes);
+ c_FREE(self->nodes);
}
}
diff --git a/include/stc/csset.h b/include/stc/csset.h
index 753ed063..1ae8c3f2 100644
--- a/include/stc/csset.h
+++ b/include/stc/csset.h
@@ -36,7 +36,7 @@ int main(void) {
csset_i_insert(&s, 3);
csset_i_insert(&s, 5);
- c_foreach (k, csset_i, s)
+ c_FOREACH (k, csset_i, s)
printf("set %d\n", *k.ref);
csset_i_drop(&s);
}
diff --git a/include/stc/cstack.h b/include/stc/cstack.h
index 5e87cf9f..9fb96e3c 100644
--- a/include/stc/cstack.h
+++ b/include/stc/cstack.h
@@ -59,12 +59,12 @@ STC_INLINE void _cx_memb(_create)(_cx_self* self)
{ self->_len = 0; self->_cap = 0; self->data = NULL; }
STC_INLINE _cx_self _cx_memb(_with_capacity)(size_t cap) {
- _cx_self out = {(_cx_value *) c_malloc(cap*sizeof(i_key)), 0, cap};
+ _cx_self out = {(_cx_value *) c_MALLOC(cap*sizeof(i_key)), 0, cap};
return out;
}
STC_INLINE _cx_self _cx_memb(_with_size)(size_t size, i_key null) {
- _cx_self out = {(_cx_value *) c_malloc(size*sizeof null), size, size};
+ _cx_self out = {(_cx_value *) c_MALLOC(size*sizeof null), size, size};
while (size) out.data[--size] = null;
return out;
}
@@ -79,7 +79,7 @@ STC_INLINE void _cx_memb(_clear)(_cx_self* self) {
STC_INLINE void _cx_memb(_drop)(_cx_self* self) {
_cx_memb(_clear)(self);
#ifndef i_capacity
- c_free(self->data);
+ c_FREE(self->data);
#endif
}
@@ -100,7 +100,7 @@ STC_INLINE size_t _cx_memb(_capacity)(const _cx_self* self) {
STC_INLINE bool _cx_memb(_reserve)(_cx_self* self, size_t n) {
if (n < self->_len) return true;
#ifndef i_capacity
- _cx_value *t = (_cx_value *)c_realloc(self->data, n*sizeof *t);
+ _cx_value *t = (_cx_value *)c_REALLOC(self->data, n*sizeof *t);
if (t) { self->_cap = n, self->data = t; return true; }
#endif
return false;
@@ -149,7 +149,7 @@ STC_INLINE _cx_value* _cx_memb(_emplace)(_cx_self* self, _cx_raw raw)
#if !defined i_no_clone
STC_INLINE _cx_self _cx_memb(_clone)(_cx_self v) {
- _cx_self out = {(_cx_value *)c_malloc(v._len*sizeof(_cx_value)), v._len, v._len};
+ _cx_self out = {(_cx_value *)c_MALLOC(v._len*sizeof(_cx_value)), v._len, v._len};
if (!out.data) out._cap = 0;
else for (size_t i = 0; i < v._len; ++v.data)
out.data[i++] = i_keyclone((*v.data));
diff --git a/include/stc/cstr.h b/include/stc/cstr.h
index 9748b72c..d1a1e765 100644
--- a/include/stc/cstr.h
+++ b/include/stc/cstr.h
@@ -62,7 +62,7 @@ enum { cstr_s_cap = sizeof(cstr_buf) - 2 };
#define cstr_l_size(s) ((s)->lon.size)
#define cstr_l_set_size(s, len) ((s)->lon.data[(s)->lon.size = (len)] = 0)
#define cstr_l_data(s) (s)->lon.data
-#define cstr_l_drop(s) c_free((s)->lon.data)
+#define cstr_l_drop(s) c_FREE((s)->lon.data)
#define cstr_is_long(s) ((s)->sml.size > 127)
STC_API char* _cstr_init(cstr* self, size_t len, size_t cap);
@@ -473,7 +473,7 @@ STC_DEF char* _cstr_internal_move(cstr* self, const size_t pos1, const size_t po
STC_DEF char* _cstr_init(cstr* self, const size_t len, const size_t cap) {
if (cap > cstr_s_cap) {
- self->lon.data = (char *)c_malloc(cap + 1);
+ self->lon.data = (char *)c_MALLOC(cap + 1);
cstr_l_set_size(self, len);
cstr_l_set_cap(self, cap);
return self->lon.data;
@@ -487,26 +487,26 @@ STC_DEF void cstr_shrink_to_fit(cstr* self) {
if (r.size == r.cap)
return;
if (r.size > cstr_s_cap) {
- self->lon.data = (char *)c_realloc(self->lon.data, r.size + 1);
+ self->lon.data = (char *)c_REALLOC(self->lon.data, r.size + 1);
cstr_l_set_cap(self, r.size);
} else if (r.cap > cstr_s_cap) {
memcpy(self->sml.data, r.data, r.size + 1);
cstr_s_set_size(self, r.size);
- c_free(r.data);
+ c_FREE(r.data);
}
}
STC_DEF char* cstr_reserve(cstr* self, const size_t cap) {
if (cstr_is_long(self)) {
if (cap > cstr_l_cap(self)) {
- self->lon.data = (char *)c_realloc(self->lon.data, cap + 1);
+ self->lon.data = (char *)c_REALLOC(self->lon.data, cap + 1);
cstr_l_set_cap(self, cap);
}
return self->lon.data;
}
/* from short to long: */
if (cap > cstr_s_cap) {
- char* data = (char *)c_malloc(cap + 1);
+ char* data = (char *)c_MALLOC(cap + 1);
const size_t len = cstr_s_size(self);
memcpy(data, self->sml.data, cstr_s_cap + 1);
self->lon.data = data;
diff --git a/include/stc/csview.h b/include/stc/csview.h
index 972bc788..638d9920 100644
--- a/include/stc/csview.h
+++ b/include/stc/csview.h
@@ -115,13 +115,13 @@ STC_API csview csview_substr_ex(csview sv, intptr_t pos, size_t n);
STC_API csview csview_slice_ex(csview sv, intptr_t p1, intptr_t p2);
STC_API csview csview_token(csview sv, const char* sep, size_t* start);
-#define c_fortoken_sv(it, inputsv, sep) \
+#define c_FORTOKEN_SV(it, inputsv, sep) \
for (struct { csview _inp, token, *ref; const char *_sep; size_t pos; } \
it = {._inp=inputsv, .token=it._inp, .ref=&it.token, ._sep=sep} \
; it.pos <= it._inp.size && (it.token = csview_token(it._inp, it._sep, &it.pos)).str ; )
-#define c_fortoken(it, input, sep) \
- c_fortoken_sv(it, csview_from(input), sep)
+#define c_FORTOKEN(it, input, sep) \
+ c_FORTOKEN_SV(it, csview_from(input), sep)
/* csview interaction with cstr: */
#ifdef CSTR_H_INCLUDED
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index 5eaefa04..40e9ad4f 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -128,7 +128,7 @@ STC_INLINE size_t _cx_memb(_size)(const _cx_self* self) { return self->_le
STC_INLINE size_t _cx_memb(_capacity)(const _cx_self* self) { return self->_cap; }
STC_INLINE bool _cx_memb(_empty)(const _cx_self* self) { return !self->_len; }
STC_INLINE _cx_raw _cx_memb(_value_toraw)(const _cx_value* val) { return i_keyto(val); }
-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_value* _cx_memb(_front)(const _cx_self* self) { return self->data; }
STC_INLINE _cx_value* _cx_memb(_back)(const _cx_self* self)
{ return self->data + self->_len - 1; }
@@ -274,13 +274,13 @@ _cx_memb(_drop)(_cx_self* self) {
if (self->_cap == 0)
return;
_cx_memb(_clear)(self);
- c_free(self->data);
+ c_FREE(self->data);
}
STC_DEF bool
_cx_memb(_reserve)(_cx_self* self, const size_t cap) {
if (cap > self->_cap || (cap && cap == self->_len)) {
- _cx_value* d = (_cx_value*)c_realloc(self->data, cap*sizeof(i_key));
+ _cx_value* d = (_cx_value*)c_REALLOC(self->data, cap*sizeof(i_key));
if (!d)
return false;
self->data = d;
diff --git a/include/stc/priv/allcaps.h b/include/stc/priv/lowcase.h
index 1e2460b5..d9ad0f93 100644
--- a/include/stc/priv/allcaps.h
+++ b/include/stc/priv/lowcase.h
@@ -20,37 +20,36 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#define c_ALLOC c_alloc
-#define c_ALLOC_N c_alloc_n
-#define c_NEW c_new
-#define c_MALLOC c_malloc
-#define c_CALLOC c_calloc
-#define c_REALLOC c_realloc
-#define c_FREE c_free
-#define c_DELETE c_delete
-#define c_SWAP c_swap
-#define c_CONTAINER_OF c_container_of
-#define c_STATIC_ASSERT c_static_assert
-#define c_ARRAYLEN c_arraylen
-#define c_OPTION c_option
-#define c_FORLIST c_forlist
-#define c_FORRANGE c_forrange
-#define c_FOREACH c_foreach
-#define c_FORWHILE c_forwhile
-#define c_FORPAIR c_forpair
-#define c_FORFILTER c_forfilter
-#define c_FORMATCH c_formatch
-#define c_FORTOKEN c_fortoken
-#define c_FORTOKEN_SV c_fortoken_sv
-#define c_AUTO c_auto
-#define c_AUTODROP c_autodrop
-#define c_WITH c_with
-#define c_SCOPE c_scope
-#define c_DEFER c_defer
-#define c_DROP c_drop
-#define c_FIND_IF c_find_if
-#define c_ERASE_IF c_erase_if
-#define c_FLT_TAKE c_flt_take
-#define c_FLT_SKIP c_flt_skip
-#define c_FLT_SKIPWHILE c_flt_skipwhile
-#define c_FLT_TAKEWHILE c_flt_takewhile
+#define c_alloc c_ALLOC
+#define c_alloc_n c_ALLOC_N
+#define c_new c_NEW
+#define c_malloc c_MALLOC
+#define c_calloc c_CALLOC
+#define c_realloc c_REALLOC
+#define c_free c_FREE
+#define c_delete c_DELETE
+#define c_swap c_SWAP
+#define c_container_of c_CONTAINER_OF
+#define c_static_assert c_STATIC_ASSERT
+#define c_arraylen c_ARRAYLEN
+#define c_forlist c_FORLIST
+#define c_forrange c_FORRANGE
+#define c_foreach c_FOREACH
+#define c_forwhile c_FORWHILE
+#define c_forpair c_FORPAIR
+#define c_forfilter c_FORFILTER
+#define c_formatch c_FORMATCH
+#define c_fortoken c_FORTOKEN
+#define c_fortoken_sv c_FORTOKEN_SV
+#define c_auto c_AUTO
+#define c_autodrop c_AUTODROP
+#define c_with c_WITH
+#define c_scope c_SCOPE
+#define c_defer c_DEFER
+#define c_drop c_DROP
+#define c_find_if c_FIND_IF
+#define c_erase_if c_ERASE_IF
+#define c_flt_take c_FLT_TAKE
+#define c_flt_skip c_FLT_SKIP
+#define c_flt_skipwhile c_FLT_SKIPWHILE
+#define c_flt_takewhile c_FLT_TAKEWHILE
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
diff --git a/misc/benchmarks/misc/cbits_benchmark.cpp b/misc/benchmarks/misc/cbits_benchmark.cpp
index dd709db1..114ab963 100644
--- a/misc/benchmarks/misc/cbits_benchmark.cpp
+++ b/misc/benchmarks/misc/cbits_benchmark.cpp
@@ -42,7 +42,7 @@ int main(int argc, char **argv)
csrandom(seed);
current_time = get_time_in_ms();
- c_forrange (40 * N)
+ c_FORRANGE (40 * N)
{
uint64_t r = crandom();
bools[r & (N-1)] = r & 1<<29;
@@ -51,7 +51,7 @@ int main(int argc, char **argv)
difference1 = get_time_in_ms() - current_time;
current_time = get_time_in_ms();
- c_forrange (100) c_forrange (num, N)
+ c_FORRANGE (100) c_FORRANGE (num, N)
{
total += bools[num];
}
@@ -70,7 +70,7 @@ int main(int argc, char **argv)
current_time = get_time_in_ms();
bitset<N> bits;
- c_forrange (40 * N)
+ c_FORRANGE (40 * N)
{
uint64_t r = crandom();
bits[r & (N-1)] = r & 1<<29;
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
difference1 = get_time_in_ms() - current_time;
current_time = get_time_in_ms();
- c_forrange (100) c_forrange (num, N)
+ c_FORRANGE (100) c_FORRANGE (num, N)
{
total += bits[num];
}
@@ -96,7 +96,7 @@ int main(int argc, char **argv)
current_time = get_time_in_ms();
cbits bits2 = cbits_with_size(N, false);
- c_forrange (40 * N)
+ c_FORRANGE (40 * N)
{
uint64_t r = crandom();
cbits_set_value(&bits2, r & (N-1), r & 1<<29);
@@ -105,7 +105,7 @@ int main(int argc, char **argv)
difference1 = get_time_in_ms() - current_time;
current_time = get_time_in_ms();
- c_forrange (100) c_forrange (num, N)
+ c_FORRANGE (100) c_FORRANGE (num, N)
{
total += cbits_at(&bits2, num);
}
diff --git a/misc/benchmarks/misc/string_bench_STC.cpp b/misc/benchmarks/misc/string_bench_STC.cpp
index 39a46d50..e252b449 100644
--- a/misc/benchmarks/misc/string_bench_STC.cpp
+++ b/misc/benchmarks/misc/string_bench_STC.cpp
@@ -98,7 +98,7 @@ void initShortStringVec(cvec_str* vs, cvec_sv* vsv)
cvec_str_emplace_back(vs, "David");
*/
size_t num = 0;
- c_foreach (i, cvec_str, *vs)
+ c_FOREACH (i, cvec_str, *vs)
{
cvec_sv_push_back(vsv, cstr_sv(i.ref));
num += cstr_size(i.ref);
@@ -113,7 +113,7 @@ void initLongStringVec(cvec_str* vs, cvec_sv* vsv)
cvec_sv_clear(vsv);
*vs = read_file("names.txt");
- c_foreach (i, cvec_str, *vs) {
+ c_FOREACH (i, cvec_str, *vs) {
cstr_append_s(i.ref, *i.ref);
cstr_append_s(i.ref, *i.ref);
cstr_append_s(i.ref, *i.ref);
@@ -144,7 +144,7 @@ void initLongStringVec(cvec_str* vs, cvec_sv* vsv)
cvec_str_emplace_back(vs, "David David David David David David");
*/
size_t num = 0;
- c_foreach (i, cvec_str, *vs)
+ c_FOREACH (i, cvec_str, *vs)
{
cvec_sv_push_back(vsv, cstr_sv(i.ref));
num += cstr_size(i.ref);
@@ -162,7 +162,7 @@ void initMaps(const cvec_str* vs, csmap_str* mapTrans, csmap_ssv* mapSview,
cmap_ssv_clear(unordmapSview);
size_t n = 0;
- c_foreach (i, cvec_str, *vs)
+ c_FOREACH (i, cvec_str, *vs)
{
csmap_str_insert(mapTrans, cstr_clone(*i.ref), n);
csmap_ssv_insert(mapSview, cstr_clone(*i.ref), n);
@@ -243,7 +243,7 @@ void benchmark(
stopwatch.start("Trans Map with char*");
for (size_t i = 0; i < MAX_LOOP; ++i)
{
- c_foreach (j, cvec_str, *vec_string)
+ c_FOREACH (j, cvec_str, *vec_string)
{
const csmap_str_value* v = csmap_str_get(mapTrans, cstr_str(j.ref));
if (v)
@@ -257,7 +257,7 @@ void benchmark(
stopwatch.start("Trans Map with string_view");
for (size_t i = 0; i < MAX_LOOP; ++i)
{
- c_foreach (j, cvec_sv, *vec_stringview)
+ c_FOREACH (j, cvec_sv, *vec_stringview)
{
const csmap_ssv_value* v = csmap_ssv_get(mapSview, *j.ref);
if (v)
@@ -271,7 +271,7 @@ void benchmark(
stopwatch.start("Trans Unord Map with char*");
for (size_t i = 0; i < MAX_LOOP; ++i)
{
- c_foreach (j, cvec_str, *vec_string)
+ c_FOREACH (j, cvec_str, *vec_string)
{
const cmap_str_value* v = cmap_str_get(unordmapTrans, cstr_str(j.ref));
if (v)
@@ -285,7 +285,7 @@ void benchmark(
stopwatch.start("Trans Unord Map with string_view");
for (size_t i = 0; i < MAX_LOOP; ++i)
{
- c_foreach (j, cvec_sv, *vec_stringview)
+ c_FOREACH (j, cvec_sv, *vec_stringview)
{
const cmap_ssv_value* v = cmap_ssv_get(unordmapSview, *j.ref);
if (v)
diff --git a/misc/benchmarks/picobench/picobench_cmap.cpp b/misc/benchmarks/picobench/picobench_cmap.cpp
index 3ffba5b9..9cc96d46 100644
--- a/misc/benchmarks/picobench/picobench_cmap.cpp
+++ b/misc/benchmarks/picobench/picobench_cmap.cpp
@@ -57,14 +57,14 @@ static void ins_and_erase_i(picobench::state& s)
csrandom(seed);
picobench::scope scope(s);
- c_forrange (s.iterations())
+ c_FORRANGE (s.iterations())
map[crandom()];
map.clear();
csrandom(seed);
- c_forrange (s.iterations())
+ c_FORRANGE (s.iterations())
map[crandom()];
csrandom(seed);
- c_forrange (s.iterations())
+ c_FORRANGE (s.iterations())
map.erase(crandom());
s.set_result(map.size());
}
@@ -75,14 +75,14 @@ static void ins_and_erase_cmap_i(picobench::state& s)
csrandom(seed);
picobench::scope scope(s);
- c_forrange (s.iterations())
+ c_FORRANGE (s.iterations())
cmap_i_insert(&map, crandom(), 0);
cmap_i_clear(&map);
csrandom(seed);
- c_forrange (s.iterations())
+ c_FORRANGE (s.iterations())
cmap_i_insert(&map, crandom(), 0);
csrandom(seed);
- c_forrange (s.iterations())
+ c_FORRANGE (s.iterations())
cmap_i_erase(&map, crandom());
s.set_result(cmap_i_size(&map));
cmap_i_drop(&map);
@@ -94,14 +94,14 @@ static void ins_and_erase_cmap_x(picobench::state& s)
csrandom(seed);
picobench::scope scope(s);
- c_forrange (s.iterations())
+ c_FORRANGE (s.iterations())
cmap_x_insert(&map, crandom(), 0);
cmap_x_clear(&map);
csrandom(seed);
- c_forrange (s.iterations())
+ c_FORRANGE (s.iterations())
cmap_x_insert(&map, crandom(), 0);
csrandom(seed);
- c_forrange (s.iterations())
+ c_FORRANGE (s.iterations())
cmap_x_erase(&map, crandom());
s.set_result(cmap_x_size(&map));
cmap_x_drop(&map);
@@ -127,7 +127,7 @@ static void ins_and_access_i(picobench::state& s)
csrandom(seed);
picobench::scope scope(s);
- c_forrange (N1)
+ c_FORRANGE (N1)
result += ++map[crandom() & mask];
s.set_result(result);
}
@@ -140,7 +140,7 @@ static void ins_and_access_cmap_i(picobench::state& s)
csrandom(seed);
picobench::scope scope(s);
- c_forrange (N1)
+ c_FORRANGE (N1)
result += ++cmap_i_insert(&map, crandom() & mask, 0).ref->second;
s.set_result(result);
cmap_i_drop(&map);
@@ -174,7 +174,7 @@ static void ins_and_access_s(picobench::state& s)
csrandom(seed);
picobench::scope scope(s);
- c_forrange (s.iterations()) {
+ c_FORRANGE (s.iterations()) {
randomize(&str[0], str.size());
map.emplace(str, str);
randomize(&str[0], str.size());
@@ -192,7 +192,7 @@ static void ins_and_access_cmap_s(picobench::state& s)
csrandom(seed);
picobench::scope scope(s);
- c_forrange (s.iterations()) {
+ c_FORRANGE (s.iterations()) {
randomize(buf, s.arg());
//if (s.arg() > 30) { printf("%s\n", buf); exit(0); }
cmap_str_emplace(&map, buf, buf);
@@ -227,7 +227,7 @@ static void iterate_x(picobench::state& s)
size_t result = 0;
// measure insert then iterate whole map
- c_forrange (n, s.iterations()) {
+ c_FORRANGE (n, s.iterations()) {
map[crandom()] = n;
if (!(n & K)) for (auto const& keyVal : map)
result += keyVal.second;
@@ -237,7 +237,7 @@ static void iterate_x(picobench::state& s)
csrandom(seed);
// measure erase then iterate whole map
- c_forrange (n, s.iterations()) {
+ c_FORRANGE (n, s.iterations()) {
map.erase(crandom());
if (!(n & K)) for (auto const& keyVal : map)
result += keyVal.second;
@@ -255,9 +255,9 @@ static void iterate_cmap_x(picobench::state& s)
size_t result = 0;
// measure insert then iterate whole map
- c_forrange (n, s.iterations()) {
+ c_FORRANGE (n, s.iterations()) {
cmap_x_insert_or_assign(&map, crandom(), n);
- if (!(n & K)) c_foreach (i, cmap_x, map)
+ if (!(n & K)) c_FOREACH (i, cmap_x, map)
result += i.ref->second;
}
@@ -265,9 +265,9 @@ static void iterate_cmap_x(picobench::state& s)
csrandom(seed);
// measure erase then iterate whole map
- c_forrange (n, s.iterations()) {
+ c_FORRANGE (n, s.iterations()) {
cmap_x_erase(&map, crandom());
- if (!(n & K)) c_foreach (i, cmap_x, map)
+ if (!(n & K)) c_FOREACH (i, cmap_x, map)
result += i.ref->second;
}
s.set_result(result);
diff --git a/misc/benchmarks/picobench/picobench_csmap.cpp b/misc/benchmarks/picobench/picobench_csmap.cpp
index 5caab6cc..9ad8f9cd 100644
--- a/misc/benchmarks/picobench/picobench_csmap.cpp
+++ b/misc/benchmarks/picobench/picobench_csmap.cpp
@@ -38,7 +38,7 @@ static void ctor_and_ins_one_i(picobench::state& s)
{
size_t result = 0;
picobench::scope scope(s);
- c_forrange (n, s.iterations()) {
+ c_FORRANGE (n, s.iterations()) {
MapInt map;
map[n];
result += map.size();
@@ -50,7 +50,7 @@ static void ctor_and_ins_one_csmap_i(picobench::state& s)
{
size_t result = 0;
picobench::scope scope(s);
- c_forrange (n, s.iterations()) {
+ c_FORRANGE (n, s.iterations()) {
csmap_i map = csmap_i_init();
csmap_i_insert(&map, n, 0);
result += csmap_i_size(&map);
@@ -73,7 +73,7 @@ static void insert_i(picobench::state& s)
MapInt map;
csrandom(seed);
picobench::scope scope(s);
- c_forrange (n, s.iterations())
+ c_FORRANGE (n, s.iterations())
map.emplace(crandom() & 0xfffffff, n);
s.set_result(map.size());
}
@@ -83,7 +83,7 @@ static void insert_csmap_i(picobench::state& s)
csmap_i map = csmap_i_init();
csrandom(seed);
picobench::scope scope(s);
- c_forrange (n, s.iterations())
+ c_FORRANGE (n, s.iterations())
csmap_i_insert(&map, crandom() & 0xfffffff, n);
s.set_result(csmap_i_size(&map));
csmap_i_drop(&map);
@@ -106,17 +106,17 @@ static void ins_and_erase_i(picobench::state& s)
csrandom(seed);
picobench::scope scope(s);
- c_forrange (i, s.iterations())
+ c_FORRANGE (i, s.iterations())
map.emplace(crandom() & mask, i);
result = map.size();
map.clear();
csrandom(seed);
- c_forrange (i, s.iterations())
+ c_FORRANGE (i, s.iterations())
map[crandom() & mask] = i;
csrandom(seed);
- c_forrange (s.iterations())
+ c_FORRANGE (s.iterations())
map.erase(crandom() & mask);
s.set_result(result);
}
@@ -129,17 +129,17 @@ static void ins_and_erase_csmap_i(picobench::state& s)
csrandom(seed);
picobench::scope scope(s);
- c_forrange (i, s.iterations())
+ c_FORRANGE (i, s.iterations())
csmap_i_insert(&map, crandom() & mask, i);
result = csmap_i_size(&map);
csmap_i_clear(&map);
csrandom(seed);
- c_forrange (i, s.iterations())
+ c_FORRANGE (i, s.iterations())
csmap_i_insert_or_assign(&map, crandom() & mask, i);
csrandom(seed);
- c_forrange (s.iterations())
+ c_FORRANGE (s.iterations())
csmap_i_erase(&map, crandom() & mask);
s.set_result(result);
csmap_i_drop(&map);
@@ -161,7 +161,7 @@ static void ins_and_access_i(picobench::state& s)
csrandom(seed);
picobench::scope scope(s);
- c_forrange (s.iterations()) {
+ c_FORRANGE (s.iterations()) {
result += ++map[crandom() & mask];
auto it = map.find(crandom() & mask);
if (it != map.end()) map.erase(it->first);
@@ -177,7 +177,7 @@ static void ins_and_access_csmap_i(picobench::state& s)
csrandom(seed);
picobench::scope scope(s);
- c_forrange (s.iterations()) {
+ c_FORRANGE (s.iterations()) {
result += ++csmap_i_insert(&map, crandom() & mask, 0).ref->second;
const csmap_i_value* val = csmap_i_get(&map, crandom() & mask);
if (val) csmap_i_erase(&map, val->first);
@@ -208,12 +208,12 @@ static void ins_and_access_s(picobench::state& s)
picobench::scope scope(s);
csrandom(seed);
- c_forrange (s.iterations()) {
+ c_FORRANGE (s.iterations()) {
randomize(&str[0], str.size());
map.emplace(str, str);
}
csrandom(seed);
- c_forrange (s.iterations()) {
+ c_FORRANGE (s.iterations()) {
randomize(&str[0], str.size());
result += map.erase(str);
}
@@ -229,12 +229,12 @@ static void ins_and_access_csmap_s(picobench::state& s)
picobench::scope scope(s);
csrandom(seed);
- c_forrange (s.iterations()) {
+ c_FORRANGE (s.iterations()) {
randomize(buf, s.arg());
csmap_str_emplace(&map, buf, buf);
}
csrandom(seed);
- c_forrange (s.iterations()) {
+ c_FORRANGE (s.iterations()) {
randomize(buf, s.arg());
result += csmap_str_erase(&map, buf);
/*csmap_str_iter it = csmap_str_find(&map, buf);
@@ -266,7 +266,7 @@ static void iterate_x(picobench::state& s)
size_t result = 0;
// measure insert then iterate whole map
- c_forrange (n, s.iterations()) {
+ c_FORRANGE (n, s.iterations()) {
map[crandom()] = n;
if (!(n & K)) for (auto const& keyVal : map)
result += keyVal.second;
@@ -276,7 +276,7 @@ static void iterate_x(picobench::state& s)
csrandom(seed);
// measure erase then iterate whole map
- c_forrange (n, s.iterations()) {
+ c_FORRANGE (n, s.iterations()) {
map.erase(crandom());
if (!(n & K)) for (auto const& keyVal : map)
result += keyVal.second;
@@ -294,9 +294,9 @@ static void iterate_csmap_x(picobench::state& s)
size_t result = 0;
// measure insert then iterate whole map
- c_forrange (n, s.iterations()) {
+ c_FORRANGE (n, s.iterations()) {
csmap_x_insert_or_assign(&map, crandom(), n);
- if (!(n & K)) c_foreach (i, csmap_x, map)
+ if (!(n & K)) c_FOREACH (i, csmap_x, map)
result += i.ref->second;
}
@@ -304,9 +304,9 @@ static void iterate_csmap_x(picobench::state& s)
csrandom(seed);
// measure erase then iterate whole map
- c_forrange (n, s.iterations()) {
+ c_FORRANGE (n, s.iterations()) {
csmap_x_erase(&map, crandom());
- if (!(n & K)) c_foreach (i, csmap_x, map)
+ if (!(n & K)) c_FOREACH (i, csmap_x, map)
result += i.ref->second;
}
s.set_result(result);
diff --git a/misc/benchmarks/plotbench/cdeq_benchmark.cpp b/misc/benchmarks/plotbench/cdeq_benchmark.cpp
index 1259cc07..ed463ee4 100644
--- a/misc/benchmarks/plotbench/cdeq_benchmark.cpp
+++ b/misc/benchmarks/plotbench/cdeq_benchmark.cpp
@@ -29,29 +29,29 @@ Sample test_std_deque() {
s.test[INSERT].t1 = clock();
container con;
csrandom(seed);
- c_forrange (N/3) con.push_front(crandom() & mask1);
- c_forrange (N/3) {con.push_back(crandom() & mask1); con.pop_front();}
- c_forrange (N/3) con.push_back(crandom() & mask1);
+ c_FORRANGE (N/3) con.push_front(crandom() & mask1);
+ c_FORRANGE (N/3) {con.push_back(crandom() & mask1); con.pop_front();}
+ c_FORRANGE (N/3) con.push_back(crandom() & mask1);
s.test[INSERT].t2 = clock();
s.test[INSERT].sum = con.size();
s.test[ERASE].t1 = clock();
- c_forrange (con.size()/2) { con.pop_front(); con.pop_back(); }
+ c_FORRANGE (con.size()/2) { con.pop_front(); con.pop_back(); }
s.test[ERASE].t2 = clock();
s.test[ERASE].sum = con.size();
}{
container con;
csrandom(seed);
- c_forrange (N) con.push_back(crandom() & mask2);
+ c_FORRANGE (N) con.push_back(crandom() & mask2);
s.test[FIND].t1 = clock();
size_t sum = 0;
// Iteration - not inherent find - skipping
//container::iterator it;
- //c_forrange (S) if ((it = std::find(con.begin(), con.end(), crandom() & mask2)) != con.end()) sum += *it;
+ //c_FORRANGE (S) if ((it = std::find(con.begin(), con.end(), crandom() & mask2)) != con.end()) sum += *it;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
s.test[ITER].t1 = clock();
sum = 0;
- c_forrange (R) c_forrange (i, N) sum += con[i];
+ c_FORRANGE (R) c_FORRANGE (i, N) sum += con[i];
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
s.test[DESTRUCT].t1 = clock();
@@ -73,29 +73,29 @@ Sample test_stc_deque() {
container con = cdeq_x_init();
//cdeq_x_reserve(&con, N);
csrandom(seed);
- c_forrange (N/3) cdeq_x_push_front(&con, crandom() & mask1);
- c_forrange (N/3) {cdeq_x_push_back(&con, crandom() & mask1); cdeq_x_pop_front(&con);}
- c_forrange (N/3) cdeq_x_push_back(&con, crandom() & mask1);
+ c_FORRANGE (N/3) cdeq_x_push_front(&con, crandom() & mask1);
+ c_FORRANGE (N/3) {cdeq_x_push_back(&con, crandom() & mask1); cdeq_x_pop_front(&con);}
+ c_FORRANGE (N/3) cdeq_x_push_back(&con, crandom() & mask1);
s.test[INSERT].t2 = clock();
s.test[INSERT].sum = cdeq_x_size(&con);
s.test[ERASE].t1 = clock();
- c_forrange (cdeq_x_size(&con)/2) { cdeq_x_pop_front(&con); cdeq_x_pop_back(&con); }
+ c_FORRANGE (cdeq_x_size(&con)/2) { cdeq_x_pop_front(&con); cdeq_x_pop_back(&con); }
s.test[ERASE].t2 = clock();
s.test[ERASE].sum = cdeq_x_size(&con);
cdeq_x_drop(&con);
}{
csrandom(seed);
container con = cdeq_x_init();
- c_forrange (N) cdeq_x_push_back(&con, crandom() & mask2);
+ c_FORRANGE (N) cdeq_x_push_back(&con, crandom() & mask2);
s.test[FIND].t1 = clock();
size_t sum = 0;
//cdeq_x_iter it, end = cdeq_x_end(&con);
- //c_forrange (S) if ((it = cdeq_x_find(&con, crandom() & mask2)).ref != end.ref) sum += *it.ref;
+ //c_FORRANGE (S) if ((it = cdeq_x_find(&con, crandom() & mask2)).ref != end.ref) sum += *it.ref;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
s.test[ITER].t1 = clock();
sum = 0;
- c_forrange (R) c_forrange (i, N) sum += con.data[i];
+ c_FORRANGE (R) c_FORRANGE (i, N) sum += con.data[i];
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
s.test[DESTRUCT].t1 = clock();
@@ -109,10 +109,10 @@ Sample test_stc_deque() {
int main(int argc, char* argv[])
{
Sample std_s[SAMPLES + 1], stc_s[SAMPLES + 1];
- c_forrange (i, SAMPLES) {
+ c_FORRANGE (i, SAMPLES) {
std_s[i] = test_std_deque();
stc_s[i] = test_stc_deque();
- if (i > 0) c_forrange (j, N_TESTS) {
+ if (i > 0) c_FORRANGE (j, N_TESTS) {
if (secs(std_s[i].test[j]) < secs(std_s[0].test[j])) std_s[0].test[j] = std_s[i].test[j];
if (secs(stc_s[i].test[j]) < secs(stc_s[0].test[j])) stc_s[0].test[j] = stc_s[i].test[j];
if (stc_s[i].test[j].sum != stc_s[0].test[j].sum) printf("Error in sum: test %lld, sample %lld\n", i, j);
@@ -122,17 +122,17 @@ int main(int argc, char* argv[])
bool header = (argc > 2 && argv[2][0] == '1');
float std_sum = 0, stc_sum = 0;
- c_forrange (j, N_TESTS) {
+ c_FORRANGE (j, N_TESTS) {
std_sum += secs(std_s[0].test[j]);
stc_sum += secs(stc_s[0].test[j]);
}
if (header) printf("Compiler,Library,C,Method,Seconds,Ratio\n");
- c_forrange (j, N_TESTS)
+ c_FORRANGE (j, N_TESTS)
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, "total", std_sum, 1.0f);
- c_forrange (j, N_TESTS)
+ c_FORRANGE (j, N_TESTS)
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
}
diff --git a/misc/benchmarks/plotbench/clist_benchmark.cpp b/misc/benchmarks/plotbench/clist_benchmark.cpp
index 04c8e8cd..aac61ebf 100644
--- a/misc/benchmarks/plotbench/clist_benchmark.cpp
+++ b/misc/benchmarks/plotbench/clist_benchmark.cpp
@@ -29,28 +29,28 @@ Sample test_std_forward_list() {
s.test[INSERT].t1 = clock();
container con;
csrandom(seed);
- c_forrange (N/2) con.push_front(crandom() & mask1);
- c_forrange (N/2) con.push_front(crandom() & mask1);
+ c_FORRANGE (N/2) con.push_front(crandom() & mask1);
+ c_FORRANGE (N/2) con.push_front(crandom() & mask1);
s.test[INSERT].t2 = clock();
s.test[INSERT].sum = 0;
s.test[ERASE].t1 = clock();
- c_forrange (N) con.pop_front();
+ c_FORRANGE (N) con.pop_front();
s.test[ERASE].t2 = clock();
s.test[ERASE].sum = 0;
}{
container con;
csrandom(seed);
- c_forrange (N) con.push_front(crandom() & mask2);
+ c_FORRANGE (N) con.push_front(crandom() & mask2);
s.test[FIND].t1 = clock();
size_t sum = 0;
container::iterator it;
// Iteration - not inherent find - skipping
- //c_forrange (S) if ((it = std::find(con.begin(), con.end(), crandom() & mask2)) != con.end()) sum += *it;
+ //c_FORRANGE (S) if ((it = std::find(con.begin(), con.end(), crandom() & mask2)) != con.end()) sum += *it;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
s.test[ITER].t1 = clock();
sum = 0;
- c_forrange (R) for (auto i: con) sum += i;
+ c_FORRANGE (R) for (auto i: con) sum += i;
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
s.test[DESTRUCT].t1 = clock();
@@ -71,28 +71,28 @@ Sample test_stc_forward_list() {
s.test[INSERT].t1 = clock();
container con = clist_x_init();
csrandom(seed);
- c_forrange (N/2) clist_x_push_front(&con, crandom() & mask1);
- c_forrange (N/2) clist_x_push_back(&con, crandom() & mask1);
+ c_FORRANGE (N/2) clist_x_push_front(&con, crandom() & mask1);
+ c_FORRANGE (N/2) clist_x_push_back(&con, crandom() & mask1);
s.test[INSERT].t2 = clock();
s.test[INSERT].sum = 0;
s.test[ERASE].t1 = clock();
- c_forrange (N) clist_x_pop_front(&con);
+ c_FORRANGE (N) clist_x_pop_front(&con);
s.test[ERASE].t2 = clock();
s.test[ERASE].sum = 0;
clist_x_drop(&con);
}{
csrandom(seed);
container con = clist_x_init();
- c_forrange (N) clist_x_push_front(&con, crandom() & mask2);
+ c_FORRANGE (N) clist_x_push_front(&con, crandom() & mask2);
s.test[FIND].t1 = clock();
size_t sum = 0;
//clist_x_iter it, end = clist_x_end(&con);
- //c_forrange (S) if ((it = clist_x_find(&con, crandom() & mask2)).ref != end.ref) sum += *it.ref;
+ //c_FORRANGE (S) if ((it = clist_x_find(&con, crandom() & mask2)).ref != end.ref) sum += *it.ref;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
s.test[ITER].t1 = clock();
sum = 0;
- c_forrange (R) c_foreach (i, clist_x, con) sum += *i.ref;
+ c_FORRANGE (R) c_FOREACH (i, clist_x, con) sum += *i.ref;
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
s.test[DESTRUCT].t1 = clock();
@@ -106,10 +106,10 @@ Sample test_stc_forward_list() {
int main(int argc, char* argv[])
{
Sample std_s[SAMPLES + 1], stc_s[SAMPLES + 1];
- c_forrange (i, SAMPLES) {
+ c_FORRANGE (i, SAMPLES) {
std_s[i] = test_std_forward_list();
stc_s[i] = test_stc_forward_list();
- if (i > 0) c_forrange (j, N_TESTS) {
+ if (i > 0) c_FORRANGE (j, N_TESTS) {
if (secs(std_s[i].test[j]) < secs(std_s[0].test[j])) std_s[0].test[j] = std_s[i].test[j];
if (secs(stc_s[i].test[j]) < secs(stc_s[0].test[j])) stc_s[0].test[j] = stc_s[i].test[j];
if (stc_s[i].test[j].sum != stc_s[0].test[j].sum) printf("Error in sum: test %lld, sample %lld\n", i, j);
@@ -119,17 +119,17 @@ int main(int argc, char* argv[])
bool header = (argc > 2 && argv[2][0] == '1');
float std_sum = 0, stc_sum = 0;
- c_forrange (j, N_TESTS) {
+ c_FORRANGE (j, N_TESTS) {
std_sum += secs(std_s[0].test[j]);
stc_sum += secs(stc_s[0].test[j]);
}
if (header) printf("Compiler,Library,C,Method,Seconds,Ratio\n");
- c_forrange (j, N_TESTS)
+ c_FORRANGE (j, N_TESTS)
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, "total", std_sum, 1.0f);
- c_forrange (j, N_TESTS)
+ c_FORRANGE (j, N_TESTS)
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
} \ No newline at end of file
diff --git a/misc/benchmarks/plotbench/cmap_benchmark.cpp b/misc/benchmarks/plotbench/cmap_benchmark.cpp
index 7a8f29d2..095b5513 100644
--- a/misc/benchmarks/plotbench/cmap_benchmark.cpp
+++ b/misc/benchmarks/plotbench/cmap_benchmark.cpp
@@ -29,30 +29,30 @@ Sample test_std_unordered_map() {
csrandom(seed);
s.test[INSERT].t1 = clock();
container con;
- c_forrange (i, N/2) con.emplace(crandom() & mask1, i);
- c_forrange (i, N/2) con.emplace(i, i);
+ c_FORRANGE (i, N/2) con.emplace(crandom() & mask1, i);
+ c_FORRANGE (i, N/2) con.emplace(i, i);
s.test[INSERT].t2 = clock();
s.test[INSERT].sum = con.size();
csrandom(seed);
s.test[ERASE].t1 = clock();
- c_forrange (N) con.erase(crandom() & mask1);
+ c_FORRANGE (N) con.erase(crandom() & mask1);
s.test[ERASE].t2 = clock();
s.test[ERASE].sum = con.size();
}{
container con;
csrandom(seed);
- c_forrange (i, N/2) con.emplace(crandom() & mask1, i);
- c_forrange (i, N/2) con.emplace(i, i);
+ c_FORRANGE (i, N/2) con.emplace(crandom() & mask1, i);
+ c_FORRANGE (i, N/2) con.emplace(i, i);
csrandom(seed);
s.test[FIND].t1 = clock();
size_t sum = 0;
container::iterator it;
- c_forrange (N) if ((it = con.find(crandom() & mask1)) != con.end()) sum += it->second;
+ c_FORRANGE (N) if ((it = con.find(crandom() & mask1)) != con.end()) sum += it->second;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
s.test[ITER].t1 = clock();
sum = 0;
- c_forrange (R) for (auto i: con) sum += i.second;
+ c_FORRANGE (R) for (auto i: con) sum += i.second;
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
s.test[DESTRUCT].t1 = clock();
@@ -73,33 +73,33 @@ Sample test_stc_unordered_map() {
csrandom(seed);
s.test[INSERT].t1 = clock();
container con = cmap_x_init();
- c_forrange (i, N/2) cmap_x_insert(&con, crandom() & mask1, i);
- c_forrange (i, N/2) cmap_x_insert(&con, i, i);
+ c_FORRANGE (i, N/2) cmap_x_insert(&con, crandom() & mask1, i);
+ c_FORRANGE (i, N/2) cmap_x_insert(&con, i, i);
s.test[INSERT].t2 = clock();
s.test[INSERT].sum = cmap_x_size(&con);
csrandom(seed);
s.test[ERASE].t1 = clock();
- c_forrange (N) cmap_x_erase(&con, crandom() & mask1);
+ c_FORRANGE (N) cmap_x_erase(&con, crandom() & mask1);
s.test[ERASE].t2 = clock();
s.test[ERASE].sum = cmap_x_size(&con);
cmap_x_drop(&con);
}{
container con = cmap_x_init();
csrandom(seed);
- c_forrange (i, N/2) cmap_x_insert(&con, crandom() & mask1, i);
- c_forrange (i, N/2) cmap_x_insert(&con, i, i);
+ c_FORRANGE (i, N/2) cmap_x_insert(&con, crandom() & mask1, i);
+ c_FORRANGE (i, N/2) cmap_x_insert(&con, i, i);
csrandom(seed);
s.test[FIND].t1 = clock();
size_t sum = 0;
const cmap_x_value* val;
- c_forrange (N)
+ c_FORRANGE (N)
if ((val = cmap_x_get(&con, crandom() & mask1)))
sum += val->second;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
s.test[ITER].t1 = clock();
sum = 0;
- c_forrange (R) c_foreach (i, cmap_x, con) sum += i.ref->second;
+ c_FORRANGE (R) c_FOREACH (i, cmap_x, con) sum += i.ref->second;
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
s.test[DESTRUCT].t1 = clock();
@@ -113,10 +113,10 @@ Sample test_stc_unordered_map() {
int main(int argc, char* argv[])
{
Sample std_s[SAMPLES + 1], stc_s[SAMPLES + 1];
- c_forrange (i, SAMPLES) {
+ c_FORRANGE (i, SAMPLES) {
std_s[i] = test_std_unordered_map();
stc_s[i] = test_stc_unordered_map();
- if (i > 0) c_forrange (j, N_TESTS) {
+ if (i > 0) c_FORRANGE (j, N_TESTS) {
if (secs(std_s[i].test[j]) < secs(std_s[0].test[j])) std_s[0].test[j] = std_s[i].test[j];
if (secs(stc_s[i].test[j]) < secs(stc_s[0].test[j])) stc_s[0].test[j] = stc_s[i].test[j];
if (stc_s[i].test[j].sum != stc_s[0].test[j].sum) printf("Error in sum: test %lld, sample %lld\n", i, j);
@@ -126,17 +126,17 @@ int main(int argc, char* argv[])
bool header = (argc > 2 && argv[2][0] == '1');
float std_sum = 0, stc_sum = 0;
- c_forrange (j, N_TESTS) {
+ c_FORRANGE (j, N_TESTS) {
std_sum += secs(std_s[0].test[j]);
stc_sum += secs(stc_s[0].test[j]);
}
if (header) printf("Compiler,Library,C,Method,Seconds,Ratio\n");
- c_forrange (j, N_TESTS)
+ c_FORRANGE (j, N_TESTS)
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, "total", std_sum, 1.0f);
- c_forrange (j, N_TESTS)
+ c_FORRANGE (j, N_TESTS)
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
} \ No newline at end of file
diff --git a/misc/benchmarks/plotbench/cpque_benchmark.cpp b/misc/benchmarks/plotbench/cpque_benchmark.cpp
index d6c2eda4..f2a85aee 100644
--- a/misc/benchmarks/plotbench/cpque_benchmark.cpp
+++ b/misc/benchmarks/plotbench/cpque_benchmark.cpp
@@ -20,14 +20,14 @@ void std_test()
std::priority_queue<float, std::vector<float>, std::greater<float>> pq;
rng = stc64_new(seed);
clock_t start = clock();
- c_forrange (i, N)
+ c_FORRANGE (i, N)
pq.push((float) stc64_randf(&rng)*100000);
printf("Built priority queue: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
printf("%g ", pq.top());
start = clock();
- c_forrange (i, N) {
+ c_FORRANGE (i, N) {
pq.pop();
}
@@ -44,18 +44,18 @@ void stc_test()
{
rng = stc64_new(seed);
clock_t start = clock();
- c_forrange (i, N)
+ c_FORRANGE (i, N)
cpque_f_push(&pq, (float) stc64_randf(&rng)*100000);
printf("Built priority queue: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
printf("%g ", *cpque_f_top(&pq));
- c_forrange (i, M) {
+ c_FORRANGE (i, M) {
cpque_f_pop(&pq);
}
start = clock();
- c_forrange (i, M, N)
+ c_FORRANGE (i, M, N)
cpque_f_pop(&pq);
printf("\npopped PQ: %f secs\n", (clock() - start) / (float) CLOCKS_PER_SEC);
}
diff --git a/misc/benchmarks/plotbench/csmap_benchmark.cpp b/misc/benchmarks/plotbench/csmap_benchmark.cpp
index 46bd695c..7dec8368 100644
--- a/misc/benchmarks/plotbench/csmap_benchmark.cpp
+++ b/misc/benchmarks/plotbench/csmap_benchmark.cpp
@@ -29,30 +29,30 @@ Sample test_std_map() {
csrandom(seed);
s.test[INSERT].t1 = clock();
container con;
- c_forrange (i, N/2) con.emplace(crandom() & mask1, i);
- c_forrange (i, N/2) con.emplace(i, i);
+ c_FORRANGE (i, N/2) con.emplace(crandom() & mask1, i);
+ c_FORRANGE (i, N/2) con.emplace(i, i);
s.test[INSERT].t2 = clock();
s.test[INSERT].sum = con.size();
csrandom(seed);
s.test[ERASE].t1 = clock();
- c_forrange (N) con.erase(crandom() & mask1);
+ c_FORRANGE (N) con.erase(crandom() & mask1);
s.test[ERASE].t2 = clock();
s.test[ERASE].sum = con.size();
}{
container con;
csrandom(seed);
- c_forrange (i, N/2) con.emplace(crandom() & mask1, i);
- c_forrange (i, N/2) con.emplace(i, i);
+ c_FORRANGE (i, N/2) con.emplace(crandom() & mask1, i);
+ c_FORRANGE (i, N/2) con.emplace(i, i);
csrandom(seed);
s.test[FIND].t1 = clock();
size_t sum = 0;
container::iterator it;
- c_forrange (N) if ((it = con.find(crandom() & mask1)) != con.end()) sum += it->second;
+ c_FORRANGE (N) if ((it = con.find(crandom() & mask1)) != con.end()) sum += it->second;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
s.test[ITER].t1 = clock();
sum = 0;
- c_forrange (R) for (auto i: con) sum += i.second;
+ c_FORRANGE (R) for (auto i: con) sum += i.second;
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
s.test[DESTRUCT].t1 = clock();
@@ -74,33 +74,33 @@ Sample test_stc_map() {
csrandom(seed);
s.test[INSERT].t1 = clock();
container con = csmap_x_init();
- c_forrange (i, N/2) csmap_x_insert(&con, crandom() & mask1, i);
- c_forrange (i, N/2) csmap_x_insert(&con, i, i);
+ c_FORRANGE (i, N/2) csmap_x_insert(&con, crandom() & mask1, i);
+ c_FORRANGE (i, N/2) csmap_x_insert(&con, i, i);
s.test[INSERT].t2 = clock();
s.test[INSERT].sum = csmap_x_size(&con);
csrandom(seed);
s.test[ERASE].t1 = clock();
- c_forrange (N) csmap_x_erase(&con, crandom() & mask1);
+ c_FORRANGE (N) csmap_x_erase(&con, crandom() & mask1);
s.test[ERASE].t2 = clock();
s.test[ERASE].sum = csmap_x_size(&con);
csmap_x_drop(&con);
}{
container con = csmap_x_init();
csrandom(seed);
- c_forrange (i, N/2) csmap_x_insert(&con, crandom() & mask1, i);
- c_forrange (i, N/2) csmap_x_insert(&con, i, i);
+ c_FORRANGE (i, N/2) csmap_x_insert(&con, crandom() & mask1, i);
+ c_FORRANGE (i, N/2) csmap_x_insert(&con, i, i);
csrandom(seed);
s.test[FIND].t1 = clock();
size_t sum = 0;
const csmap_x_value* val;
- c_forrange (N)
+ c_FORRANGE (N)
if ((val = csmap_x_get(&con, crandom() & mask1)))
sum += val->second;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
s.test[ITER].t1 = clock();
sum = 0;
- c_forrange (R) c_foreach (i, csmap_x, con) sum += i.ref->second;
+ c_FORRANGE (R) c_FOREACH (i, csmap_x, con) sum += i.ref->second;
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
s.test[DESTRUCT].t1 = clock();
@@ -114,10 +114,10 @@ Sample test_stc_map() {
int main(int argc, char* argv[])
{
Sample std_s[SAMPLES + 1], stc_s[SAMPLES + 1];
- c_forrange (i, SAMPLES) {
+ c_FORRANGE (i, SAMPLES) {
std_s[i] = test_std_map();
stc_s[i] = test_stc_map();
- if (i > 0) c_forrange (j, N_TESTS) {
+ if (i > 0) c_FORRANGE (j, N_TESTS) {
if (secs(std_s[i].test[j]) < secs(std_s[0].test[j])) std_s[0].test[j] = std_s[i].test[j];
if (secs(stc_s[i].test[j]) < secs(stc_s[0].test[j])) stc_s[0].test[j] = stc_s[i].test[j];
if (stc_s[i].test[j].sum != stc_s[0].test[j].sum) printf("Error in sum: test %lld, sample %lld\n", i, j);
@@ -127,17 +127,17 @@ int main(int argc, char* argv[])
bool header = (argc > 2 && argv[2][0] == '1');
float std_sum = 0, stc_sum = 0;
- c_forrange (j, N_TESTS) {
+ c_FORRANGE (j, N_TESTS) {
std_sum += secs(std_s[0].test[j]);
stc_sum += secs(stc_s[0].test[j]);
}
if (header) printf("Compiler,Library,C,Method,Seconds,Ratio\n");
- c_forrange (j, N_TESTS)
+ c_FORRANGE (j, N_TESTS)
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, "total", std_sum, 1.0f);
- c_forrange (j, N_TESTS)
+ c_FORRANGE (j, N_TESTS)
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
}
diff --git a/misc/benchmarks/plotbench/cvec_benchmark.cpp b/misc/benchmarks/plotbench/cvec_benchmark.cpp
index fe7e09fb..466c7ff2 100644
--- a/misc/benchmarks/plotbench/cvec_benchmark.cpp
+++ b/misc/benchmarks/plotbench/cvec_benchmark.cpp
@@ -29,27 +29,27 @@ Sample test_std_vector() {
s.test[INSERT].t1 = clock();
container con;
csrandom(seed);
- c_forrange (N) con.push_back(crandom() & mask1);
+ c_FORRANGE (N) con.push_back(crandom() & mask1);
s.test[INSERT].t2 = clock();
s.test[INSERT].sum = con.size();
s.test[ERASE].t1 = clock();
- c_forrange (N) con.pop_back();
+ c_FORRANGE (N) con.pop_back();
s.test[ERASE].t2 = clock();
s.test[ERASE].sum = con.size();
}{
container con;
csrandom(seed);
- c_forrange (N) con.push_back(crandom() & mask2);
+ c_FORRANGE (N) con.push_back(crandom() & mask2);
s.test[FIND].t1 = clock();
size_t sum = 0;
//container::iterator it;
// Iteration - not inherent find - skipping
- //c_forrange (S) if ((it = std::find(con.begin(), con.end(), crandom() & mask2)) != con.end()) sum += *it;
+ //c_FORRANGE (S) if ((it = std::find(con.begin(), con.end(), crandom() & mask2)) != con.end()) sum += *it;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
s.test[ITER].t1 = clock();
sum = 0;
- c_forrange (R) c_forrange (i, N) sum += con[i];
+ c_FORRANGE (R) c_FORRANGE (i, N) sum += con[i];
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
s.test[DESTRUCT].t1 = clock();
@@ -71,27 +71,27 @@ Sample test_stc_vector() {
s.test[INSERT].t1 = clock();
container con = cvec_x_init();
csrandom(seed);
- c_forrange (N) cvec_x_push_back(&con, crandom() & mask1);
+ c_FORRANGE (N) cvec_x_push_back(&con, crandom() & mask1);
s.test[INSERT].t2 = clock();
s.test[INSERT].sum = cvec_x_size(&con);
s.test[ERASE].t1 = clock();
- c_forrange (N) { cvec_x_pop_back(&con); }
+ c_FORRANGE (N) { cvec_x_pop_back(&con); }
s.test[ERASE].t2 = clock();
s.test[ERASE].sum = cvec_x_size(&con);
cvec_x_drop(&con);
}{
csrandom(seed);
container con = cvec_x_init();
- c_forrange (N) cvec_x_push_back(&con, crandom() & mask2);
+ c_FORRANGE (N) cvec_x_push_back(&con, crandom() & mask2);
s.test[FIND].t1 = clock();
size_t sum = 0;
//cvec_x_iter it, end = cvec_x_end(&con);
- //c_forrange (S) if ((it = cvec_x_find(&con, crandom() & mask2)).ref != end.ref) sum += *it.ref;
+ //c_FORRANGE (S) if ((it = cvec_x_find(&con, crandom() & mask2)).ref != end.ref) sum += *it.ref;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
s.test[ITER].t1 = clock();
sum = 0;
- c_forrange (R) c_forrange (i, N) sum += con.data[i];
+ c_FORRANGE (R) c_FORRANGE (i, N) sum += con.data[i];
s.test[ITER].t2 = clock();
s.test[ITER].sum = sum;
s.test[DESTRUCT].t1 = clock();
@@ -105,10 +105,10 @@ Sample test_stc_vector() {
int main(int argc, char* argv[])
{
Sample std_s[SAMPLES + 1] = {{NULL}}, stc_s[SAMPLES + 1] = {{NULL}};
- c_forrange (i, SAMPLES) {
+ c_FORRANGE (i, SAMPLES) {
std_s[i] = test_std_vector();
stc_s[i] = test_stc_vector();
- if (i > 0) c_forrange (j, N_TESTS) {
+ if (i > 0) c_FORRANGE (j, N_TESTS) {
if (secs(std_s[i].test[j]) < secs(std_s[0].test[j])) std_s[0].test[j] = std_s[i].test[j];
if (secs(stc_s[i].test[j]) < secs(stc_s[0].test[j])) stc_s[0].test[j] = stc_s[i].test[j];
if (stc_s[i].test[j].sum != stc_s[0].test[j].sum) printf("Error in sum: test %lld, sample %lld\n", i, j);
@@ -118,17 +118,17 @@ int main(int argc, char* argv[])
bool header = (argc > 2 && argv[2][0] == '1');
float std_sum = 0, stc_sum = 0;
- c_forrange (j, N_TESTS) {
+ c_FORRANGE (j, N_TESTS) {
std_sum += secs(std_s[0].test[j]);
stc_sum += secs(stc_s[0].test[j]);
}
if (header) printf("Compiler,Library,C,Method,Seconds,Ratio\n");
- c_forrange (j, N_TESTS)
+ c_FORRANGE (j, N_TESTS)
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, operations[j], secs(std_s[0].test[j]), 1.0f);
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, std_s[0].name, N, "total", std_sum, 1.0f);
- c_forrange (j, N_TESTS)
+ c_FORRANGE (j, N_TESTS)
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, operations[j], secs(stc_s[0].test[j]), secs(std_s[0].test[j]) ? secs(stc_s[0].test[j])/secs(std_s[0].test[j]) : 1.0f);
printf("%s,%s n:%d,%s,%.3f,%.3f\n", comp, stc_s[0].name, N, "total", stc_sum, stc_sum/std_sum);
}
diff --git a/misc/benchmarks/shootout_hashmaps.cpp b/misc/benchmarks/shootout_hashmaps.cpp
index 78d7bce2..7c5095f6 100644
--- a/misc/benchmarks/shootout_hashmaps.cpp
+++ b/misc/benchmarks/shootout_hashmaps.cpp
@@ -48,7 +48,7 @@ KHASH_MAP_INIT_INT64(ii, IValue)
#define CMAP_EMPLACE(X, key, val) cmap_##X##_insert(&map, key, val).ref->second
#define CMAP_ERASE(X, key) cmap_##X##_erase(&map, key)
#define CMAP_FIND(X, key) cmap_##X##_contains(&map, key)
-#define CMAP_FOR(X, i) c_foreach (i, cmap_##X, map)
+#define CMAP_FOR(X, i) c_FOREACH (i, cmap_##X, map)
#define CMAP_ITEM(X, i) i.ref->second
#define CMAP_SIZE(X) cmap_##X##_size(&map)
#define CMAP_BUCKETS(X) cmap_##X##_bucket_count(&map)
diff --git a/misc/examples/sidebyside.cpp b/misc/examples/sidebyside.cpp
index ca80664d..11328668 100644
--- a/misc/examples/sidebyside.cpp
+++ b/misc/examples/sidebyside.cpp
@@ -31,7 +31,7 @@ int main() {
IIMap_insert(&hist, 13, 100).ref->second += 1;
IIMap_insert(&hist, 12, 100).ref->second += 1;
- c_foreach (i, IIMap, hist)
+ c_FOREACH (i, IIMap, hist)
printf("%d, %d\n", i.ref->first, i.ref->second);
puts("");
}
@@ -50,7 +50,7 @@ int main() {
c_FORLIST (i, SIMap_raw, {{"burger", 5}, {"pizza", 12}, {"steak", 15}})
SIMap_emplace(&food, c_PAIR(i.ref));
- c_foreach (i, SIMap, food)
+ c_FOREACH (i, SIMap, food)
printf("%s, %d\n", cstr_str(&i.ref->first), i.ref->second);
puts("");
}
diff --git a/src/checkauto.l b/src/checkauto.l
index c42d97cf..b61c7cb3 100644
--- a/src/checkauto.l
+++ b/src/checkauto.l
@@ -1,4 +1,4 @@
-/* Check for illegal return/break/continue usage inside a STC-lib c_auto* block (RAII).
+/* Check for illegal return/break/continue usage inside a STC-lib c_AUTO* block (RAII).
* Copyright Tyge Løvset, (c) 2022.
*/
%{
@@ -53,7 +53,12 @@ c_with |
c_scope |
c_defer |
c_autodrop |
-c_auto { block_type = AUTO; state = BRACES; }
+c_auto |
+c_WITH |
+c_SCOPE |
+c_DEFER |
+c_AUTODROP |
+c_AUTO { block_type = AUTO; state = BRACES; }
\( { if (state == BRACES) ++braces_lev; }
\) { if (state == BRACES && --braces_lev == 0) {
state = BRACESDONE;
@@ -61,8 +66,8 @@ c_auto { block_type = AUTO; state = BRACES; }
}
if { if (state == BRACESDONE) {
if (block_type == AUTO) {
- printf("%s:%d: warning: 'if' after c_auto* not enclosed in curly braces.\n"
- " Make sure to enclose 'if - else' statement in { } after c_auto*.\n",
+ printf("%s:%d: warning: 'if' after c_AUTO* not enclosed in curly braces.\n"
+ " Make sure to enclose 'if - else' statement in { } after c_AUTO*.\n",
fname, yylineno);
++warnings;
}
@@ -78,41 +83,24 @@ if { if (state == BRACESDONE) {
\{ { if (state != BRACES) { block[++block_lev] = block_type; state = NORMAL; } }
\} { if (state != BRACES) block_type = block[--block_lev]; }
return { if (block_type == AUTO) {
- printf("%s:%d: error: 'return' used inside a c_auto* scope.\n"
- //" Use 'c_breakauto' to exit the current c_auto* scope.\n"
+ printf("%s:%d: error: 'return' used inside a c_AUTO* scope.\n"
+ " Use 'continue' to exit the current c_AUTO* scope before return.\n"
, fname, yylineno);
++errors;
} else if (block_type & AUTO) {
- printf("%s:%d: error: 'return' used in a loop inside a c_auto* scope.\n"
- //" Use 'break' to exit loops, then 'c_breakauto' to exit c_auto*.\n"
+ printf("%s:%d: error: 'return' used in a loop inside a c_AUTO* scope.\n"
+ " Use 'break' to exit loop, then 'continue' to exit c_AUTO*.\n"
, fname, yylineno);
++errors;
}
}
break { if (block_type == AUTO) {
- printf("%s:%d: error: 'break' used inside a c_auto* scope.\n"
- //" Use 'c_breakauto' to exit the current c_auto* scope.\n"
+ printf("%s:%d: error: 'break' used inside a c_AUTO* scope.\n"
+ " Use 'continue' to exit the current c_AUTO* scope.\n"
, fname, yylineno);
++errors;
}
}
-continue { if (block_type == AUTO) {
- printf("%s:%d: warning: 'continue' used inside a c_auto* scope.\n"
- " It will only break out of the current c_auto* scope.\n"
- //" Use 'c_breakauto' instead to make it explicit.\n"
- , fname, yylineno);
- ++warnings;
- }
- }
-c_breakauto { if (block_type != AUTO) {
- /*
- printf("%s:%d: warning: 'c_breakauto' used outside a c_auto* scope.\n"
- " Did you mean 'continue' instead?"
- , fname, yylineno);
- ++warnings;
- */
- }
- }
{ID} ;
\n ++yylineno;
. ;
diff --git a/src/cregex.c b/src/cregex.c
index d19b063f..e59e21a4 100644
--- a/src/cregex.c
+++ b/src/cregex.c
@@ -530,7 +530,7 @@ _optimize(_Parser *par, _Reprog *pp)
*/
intptr_t ipp = (intptr_t)pp;
size_t size = sizeof(_Reprog) + (size_t)(par->freep - pp->firstinst)*sizeof(_Reinst);
- _Reprog *npp = (_Reprog *)c_realloc(pp, size);
+ _Reprog *npp = (_Reprog *)c_REALLOC(pp, size);
ptrdiff_t diff = (intptr_t)npp - ipp;
if ((npp == NULL) | (diff == 0))
@@ -816,10 +816,10 @@ _regcomp1(_Reprog *progp, _Parser *par, const char *s, int cflags)
/* get memory for the program. estimated max usage */
const size_t instcap = 5 + 6*strlen(s);
- _Reprog* pp = (_Reprog *)c_realloc(progp, sizeof(_Reprog) + instcap*sizeof(_Reinst));
+ _Reprog* pp = (_Reprog *)c_REALLOC(progp, sizeof(_Reprog) + instcap*sizeof(_Reinst));
if (pp == NULL) {
par->error = CREG_OUTOFMEMORY;
- c_free(progp);
+ c_FREE(progp);
return NULL;
}
pp->flags.icase = (cflags & CREG_C_ICASE) != 0;
@@ -870,7 +870,7 @@ _regcomp1(_Reprog *progp, _Parser *par, const char *s, int cflags)
pp->nsubids = (unsigned)par->cursubid;
out:
if (par->error) {
- c_free(pp);
+ c_FREE(pp);
pp = NULL;
}
return pp;
@@ -1105,7 +1105,7 @@ _regexec2(const _Reprog *progp, /* program to run */
_Relist *relists;
/* mark space */
- relists = (_Relist *)c_malloc(2 * _BIGLISTSIZE*sizeof(_Relist));
+ relists = (_Relist *)c_MALLOC(2 * _BIGLISTSIZE*sizeof(_Relist));
if (relists == NULL)
return -1;
@@ -1115,7 +1115,7 @@ _regexec2(const _Reprog *progp, /* program to run */
j->reliste[1] = relists + 2*_BIGLISTSIZE - 2;
rv = _regexec1(progp, bol, mp, ms, j, mflags);
- c_free(relists);
+ c_FREE(relists);
return rv;
}
@@ -1281,6 +1281,6 @@ cregex_replace_pattern_ex(const char* pattern, const char* input, const char* re
void
cregex_drop(cregex* self) {
- c_free(self->prog);
+ c_FREE(self->prog);
}
#endif