summaryrefslogtreecommitdiffhomepage
path: root/stc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2020-09-18 11:55:29 +0200
committerTyge Løvset <[email protected]>2020-09-18 11:55:29 +0200
commit681873e4cb6ea076b79c6c70b2df2ba4e4c19bda (patch)
tree69c0c3290189163937d4ab4203fe4565094657b0 /stc
parent692ab82818e2d65177e06d7717d9184b7bc27ff1 (diff)
downloadSTC-modified-681873e4cb6ea076b79c6c70b2df2ba4e4c19bda.tar.gz
STC-modified-681873e4cb6ea076b79c6c70b2df2ba4e4c19bda.zip
Changed <container>_ini macro constant to <container>_INIT, and <container>_destroy() to <container>_del.
Diffstat (limited to 'stc')
-rw-r--r--stc/carray.h8
-rw-r--r--stc/cbitset.h6
-rw-r--r--stc/cdefs.h18
-rw-r--r--stc/clist.h18
-rw-r--r--stc/cmap.h44
-rw-r--r--stc/coption.h6
-rw-r--r--stc/cpqueue.h4
-rw-r--r--stc/cqueue.h4
-rw-r--r--stc/cstack.h2
-rw-r--r--stc/cstr.h22
-rw-r--r--stc/cvec.h16
11 files changed, 74 insertions, 74 deletions
diff --git a/stc/carray.h b/stc/carray.h
index a2f0a6ea..5a525d66 100644
--- a/stc/carray.h
+++ b/stc/carray.h
@@ -40,8 +40,8 @@ int main()
printf("%f\n", *carray2f_at(a2, 4, 3)); // lookup a2[4][3] (=10.2f)
printf("%f\n", *carray3f_at(a3, 5, 4, 3)); // same data location, via a3 array.
- carray2f_destroy(&a2); // does nothing, since it is a sub-array.
- carray3f_destroy(&a3); // also invalidates a2.
+ carray2f_del(&a2); // does nothing, since it is a sub-array.
+ carray3f_del(&a3); // also invalidates a2.
}
*/
@@ -83,7 +83,7 @@ STC_INLINE size_t _carray3_size(const size_t* zdim) {
carray##D##X##_next(carray##D##X##_iter_t* it) {++it->get;} \
\
STC_INLINE void \
- carray##D##X##_destroy(carray##D##X* self) { \
+ carray##D##X##_del(carray##D##X* self) { \
if (self->_xdim & _carray_OWN) { \
c_foreach_3 (i, carray##D##X, *self) \
valueDestroy(i.get); \
@@ -93,7 +93,7 @@ STC_INLINE size_t _carray3_size(const size_t* zdim) {
#define using_carray(...) c_MACRO_OVERLOAD(using_carray, __VA_ARGS__)
#define using_carray_2(X, Value) \
- using_carray_3(X, Value, c_default_destroy)
+ using_carray_3(X, Value, c_default_del)
#define using_carray_3(X, Value, valueDestroy) \
diff --git a/stc/cbitset.h b/stc/cbitset.h
index b20aedd2..7801423f 100644
--- a/stc/cbitset.h
+++ b/stc/cbitset.h
@@ -37,7 +37,7 @@ int main() {
cbitset_resize(&bset, 102, true);
cbitset_set_value(&bset, 99, false);
printf("%4zu: ", bset.size); for (int i=0; i<bset.size; ++i) printf("%d", cbitset_test(&bset, i)); puts("");
- cbitset_destroy(&bset);
+ cbitset_del(&bset);
}
*/
#ifndef CBITSET__H__
@@ -47,7 +47,7 @@ int main() {
typedef struct cbitset { uint64_t* _arr; size_t size; } cbitset_t;
-#define cbitset_ini {NULL, 0}
+#define cbitset_INIT {NULL, 0}
STC_API void cbitset_resize(cbitset_t* self, size_t size, bool value);
STC_API size_t cbitset_count(cbitset_t set);
@@ -104,7 +104,7 @@ STC_INLINE cbitset_t cbitset_clone(cbitset_t other) {
cbitset_t set = {(uint64_t *) memcpy(malloc(bytes), other._arr, bytes), other.size};
return set;
}
-STC_INLINE void cbitset_destroy(cbitset_t* self) {
+STC_INLINE void cbitset_del(cbitset_t* self) {
free(self->_arr);
}
diff --git a/stc/cdefs.h b/stc/cdefs.h
index f73eec06..c10d3899 100644
--- a/stc/cdefs.h
+++ b/stc/cdefs.h
@@ -78,29 +78,29 @@
#define c_default_less(x, y) (*(x) < *(y))
#define c_less_compare(less, x, y) (less(x, y) ? -1 : less(y, x))
#define c_default_compare(x, y) c_less_compare(c_default_less, x, y)
-#define c_default_destroy(ptr) ((void) (ptr))
+#define c_default_del(ptr) ((void) (ptr))
#define c_foreach(...) c_MACRO_OVERLOAD(c_foreach, __VA_ARGS__)
-
#define c_foreach_3(it, ctype, cnt) \
for (ctype##_iter_t it = ctype##_begin(&cnt), it##_end_ = ctype##_end(&cnt); it.get != it##_end_.get; ctype##_next(&it))
#define c_foreach_4(it, ctype, start, finish) \
for (ctype##_iter_t it = start, it##_end_ = finish; it.get != it##_end_.get; ctype##_next(&it))
+#define c_for_range(...) c_MACRO_OVERLOAD(c_for_range, __VA_ARGS__)
+#define c_for_range_3(type, i, stop) for (type i=0, i##_end_=stop; i < i##_end_; ++i)
+#define c_for_range_4(type, i, start, stop) for (type i=start, i##_end_=stop; i < i##_end_; ++i)
+#define c_for_range_5(type, i, start, stop, step) \
+ for (type i=start, i##_inc_=step, i##_end_=stop - (i##_inc_ > 0); (i <= i##_end_) == (0 < i##_inc_); i += i##_inc_)
+
#define c_push_items(self, ctype, ...) do { \
const ctype##_input_t __arr[] = __VA_ARGS__; \
ctype##_push_n(self, __arr, sizeof(__arr)/sizeof(__arr[0])); \
} while (0)
-#define c_apply(array, type, value, n) do { \
- type __val = value, *__i = array, *__last = __i + (n); \
- while (__i != __last) = *__i++ = __val; \
-} while (0)
-
-#define c_dtor(ctype, ...) do { \
+#define c_del_(ctype, ...) do { \
struct ctype* __arr[] = {__VA_ARGS__}; \
for (size_t i=0; i<sizeof(__arr)/sizeof(__arr[0]); ++i) \
- ctype##_destroy(__arr[i]); \
+ ctype##_del(__arr[i]); \
} while (0)
#endif
diff --git a/stc/clist.h b/stc/clist.h
index 6a8c13f7..9eb8f7b6 100644
--- a/stc/clist.h
+++ b/stc/clist.h
@@ -38,7 +38,7 @@
using_clist(ix, int64_t);
int main() {
- clist_ix list = clist_ini;
+ clist_ix list = clist_INIT;
crand_rng32_t pcg = crand_rng32_init(12345);
int n;
for (int i=0; i<1000000; ++i) // one million
@@ -52,19 +52,19 @@
puts("sorted");
c_foreach (i, clist_ix, list)
if (++n % 10000 == 0) printf("%8d: %10zd\n", n, i.get->value);
- clist_ix_destroy(&list);
+ clist_ix_del(&list);
}
*/
#define using_clist(...) c_MACRO_OVERLOAD(using_clist, __VA_ARGS__)
#define using_clist_2(X, Value) \
- using_clist_3(X, Value, c_default_destroy)
+ using_clist_3(X, Value, c_default_del)
#define using_clist_3(X, Value, valueDestroy) \
using_clist_4(X, Value, valueDestroy, c_default_compare)
#define using_clist_4(X, Value, valueDestroy, valueCompare) \
using_clist_7(X, Value, valueDestroy, Value, \
valueCompare, c_default_to_raw, c_default_from_raw)
-#define using_clist_str() using_clist_7(str, cstr_t, cstr_destroy, const char*, \
+#define using_clist_str() using_clist_7(str, cstr_t, cstr_del, const char*, \
cstr_compare_raw, cstr_to_raw, cstr)
#define using_clist_types(X, Value) \
@@ -85,7 +85,7 @@
int _state; \
} clist_##X##_iter_t
-#define clist_ini {NULL}
+#define clist_INIT {NULL}
#define clist_empty(list) ((list).last == NULL)
#define c_emplace_after(self, ctype, pos, ...) do { \
@@ -108,7 +108,7 @@ STC_API size_t _clist_size(const clist_void* self);
typedef clist_##X##_rawvalue_t clist_##X##_input_t; \
\
STC_INLINE clist_##X \
- clist_##X##_init(void) {clist_##X x = clist_ini; return x;} \
+ clist_##X##_init(void) {clist_##X x = clist_INIT; return x;} \
STC_INLINE bool \
clist_##X##_empty(clist_##X ls) {return clist_empty(ls);} \
STC_INLINE size_t \
@@ -117,9 +117,9 @@ STC_API size_t _clist_size(const clist_void* self);
clist_##X##_value_from_raw(RawValue rawValue) {return valueFromRaw(rawValue);} \
\
STC_API void \
- clist_##X##_destroy(clist_##X* self); \
+ clist_##X##_del(clist_##X* self); \
STC_INLINE void \
- clist_##X##_clear(clist_##X* self) {clist_##X##_destroy(self);} \
+ clist_##X##_clear(clist_##X* self) {clist_##X##_del(self);} \
\
STC_API void \
clist_##X##_push_n(clist_##X *self, const clist_##X##_input_t in[], size_t size); \
@@ -214,7 +214,7 @@ STC_API size_t _clist_size(const clist_void* self);
#define _c_implement_clist_7(X, Value, valueDestroy, RawValue, valueCompareRaw, valueToRaw, valueFromRaw) \
\
STC_API void \
- clist_##X##_destroy(clist_##X* self) { \
+ clist_##X##_del(clist_##X* self) { \
while (self->last) _clist_##X##_erase_after(self, self->last); \
} \
\
diff --git a/stc/cmap.h b/stc/cmap.h
index 1cd2f180..7dfbe58f 100644
--- a/stc/cmap.h
+++ b/stc/cmap.h
@@ -27,14 +27,14 @@ using_cset(sx, int); // Set of int
using_cmap(mx, int, char); // Map of int -> char
int main(void) {
- cset_sx s = cset_ini;
+ cset_sx s = cset_INIT;
cset_sx_insert(&s, 5);
cset_sx_insert(&s, 8);
c_foreach (i, cset_sx, s)
printf("set %d\n", i.get->second);
- cset_sx_destroy(&s);
+ cset_sx_del(&s);
- cmap_mx m = cmap_ini;
+ cmap_mx m = cmap_INIT;
cmap_mx_put(&m, 5, 'a');
cmap_mx_put(&m, 8, 'b');
cmap_mx_put(&m, 12, 'c');
@@ -44,7 +44,7 @@ int main(void) {
cmap_mx_erase(&m, 8);
c_foreach (i, cmap_mx, m)
printf("map %d: %c\n", i.get->first, i.get->second);
- cmap_mx_destroy(&m);
+ cmap_mx_del(&m);
}*/
#ifndef CMAP__H__
#define CMAP__H__
@@ -53,10 +53,10 @@ int main(void) {
#include <string.h>
#include "cdefs.h"
-#define cmap_ini {NULL, NULL, 0, 0, 0.85f, 0.15f}
+#define cmap_INIT {NULL, NULL, 0, 0, 0.85f, 0.15f}
#define cmap_empty(m) ((m).size == 0)
#define cmap_size(m) ((size_t) (m).size)
-#define cset_ini cmap_ini
+#define cset_INIT cmap_INIT
#define cset_empty(s) cmap_empty(s)
#define cset_size(s) cmap_size(s)
@@ -80,14 +80,14 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t;
c_MACRO_OVERLOAD(using_cmap, __VA_ARGS__)
#define using_cmap_3(X, Key, Mapped) \
- using_cmap_4(X, Key, Mapped, c_default_destroy)
+ using_cmap_4(X, Key, Mapped, c_default_del)
#define using_cmap_4(X, Key, Mapped, valueDestroy) \
using_cmap_6(X, Key, Mapped, valueDestroy, c_default_equals, c_default_hash16)
#define using_cmap_6(X, Key, Mapped, valueDestroy, keyEquals, keyHash) \
using_cmap_10(X, Key, Mapped, valueDestroy, keyEquals, keyHash, \
- c_default_destroy, Key, c_default_to_raw, c_default_from_raw)
+ c_default_del, Key, c_default_to_raw, c_default_from_raw)
#define using_cmap_10(X, Key, Mapped, valueDestroy, keyEqualsRaw, keyHashRaw, \
keyDestroy, RawKey, keyToRaw, keyFromRaw) \
@@ -107,7 +107,7 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t;
using_cset_4(X, Key, c_default_equals, c_default_hash16)
#define using_cset_4(X, Key, keyEquals, keyHash) \
- using_cset_5(X, Key, keyEquals, keyHash, c_default_destroy)
+ using_cset_5(X, Key, keyEquals, keyHash, c_default_del)
#define using_cset_5(X, Key, keyEquals, keyHash, keyDestroy) \
using_cset_8(X, Key, keyEquals, keyHash, keyDestroy, \
@@ -123,14 +123,14 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t;
_c_declare_CHASH_strkey(str, cset, cstr_t, void)
#define using_cmap_str() \
- _c_typedef_CHASH(str, cmap, cstr_t, cstr_t, cstr_destroy, cstr_equals_raw, cstr_hash_raw, \
- cstr_destroy, const char*, cstr_to_raw, cstr, const char*, cstr)
+ _c_typedef_CHASH(str, cmap, cstr_t, cstr_t, cstr_del, cstr_equals_raw, cstr_hash_raw, \
+ cstr_del, const char*, cstr_to_raw, cstr, const char*, cstr)
#define using_cmap_strkey(...) \
c_MACRO_OVERLOAD(using_cmap_strkey, __VA_ARGS__)
#define using_cmap_strkey_2(X, Mapped) \
- _c_declare_CHASH_strkey(X, cmap, Mapped, c_default_destroy)
+ _c_declare_CHASH_strkey(X, cmap, Mapped, c_default_del)
#define using_cmap_strkey_3(X, Mapped, ValueDestroy) \
_c_declare_CHASH_strkey(X, cmap, Mapped, ValueDestroy)
@@ -143,16 +143,16 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t;
#define using_cmap_strval_4(X, Key, keyEquals, keyHash) \
using_cmap_strval_8(X, Key, keyEquals, keyHash, \
- c_default_destroy, Key, c_default_to_raw, c_default_from_raw)
+ c_default_del, Key, c_default_to_raw, c_default_from_raw)
#define using_cmap_strval_8(X, Key, keyEquals, keyHash, keyDestroy, RawKey, keyToRaw, keyFromRaw) \
- _c_typedef_CHASH(X, cmap, Key, cstr_t, cstr_destroy, keyEquals, keyHash, \
+ _c_typedef_CHASH(X, cmap, Key, cstr_t, cstr_del, keyEquals, keyHash, \
keyDestroy, RawKey, keyToRaw, keyFromRaw, const char*, cstr)
#define _c_declare_CHASH_strkey(X, ctype, Mapped, valueDestroy) \
_c_typedef_CHASH(X, ctype, cstr_t, Mapped, valueDestroy, cstr_equals_raw, cstr_hash_raw, \
- cstr_destroy, const char*, cstr_to_raw, cstr, Mapped, c_default_from_raw)
+ cstr_del, const char*, cstr_to_raw, cstr, Mapped, c_default_from_raw)
#define CSET_ONLY_cset(...) __VA_ARGS__
#define CSET_ONLY_cmap(...)
@@ -175,7 +175,7 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t;
ctype##_##X##_value_t, ctype##_##X##_entry_t; \
\
STC_INLINE void \
- ctype##_##X##_entry_destroy(ctype##_##X##_value_t* e) { \
+ ctype##_##X##_entry_del(ctype##_##X##_value_t* e) { \
keyDestroy(&KEY_REF_##ctype(e)); \
CMAP_ONLY_##ctype(valueDestroy(&e->second);) \
} \
@@ -203,7 +203,7 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t;
} ctype##_##X##_iter_t; \
\
STC_INLINE ctype##_##X \
- ctype##_##X##_init(void) {ctype##_##X m = cmap_ini; return m;} \
+ ctype##_##X##_init(void) {ctype##_##X m = cmap_INIT; return m;} \
STC_INLINE bool \
ctype##_##X##_empty(ctype##_##X m) {return m.size == 0;} \
STC_INLINE size_t \
@@ -225,7 +225,7 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t;
STC_API void \
ctype##_##X##_push_n(ctype##_##X* self, const ctype##_##X##_input_t in[], size_t size); \
STC_API void \
- ctype##_##X##_destroy(ctype##_##X* self); \
+ ctype##_##X##_del(ctype##_##X* self); \
STC_API void \
ctype##_##X##_clear(ctype##_##X* self); \
STC_API ctype##_##X##_value_t* \
@@ -318,7 +318,7 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t;
keyDestroy, RawKey, keyToRaw, keyFromRaw, RawVal, valueFromRaw) \
STC_API ctype##_##X \
ctype##_##X##_with_capacity(size_t cap) { \
- ctype##_##X h = ctype##_ini; \
+ ctype##_##X h = ctype##_INIT; \
ctype##_##X##_reserve(&h, cap); \
return h; \
} \
@@ -332,10 +332,10 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t;
if (self->size == 0) return; \
ctype##_##X##_value_t* e = self->table, *end = e + self->bucket_count; \
uint8_t *hx = self->_hashx; \
- for (; e != end; ++e) if (*hx++) ctype##_##X##_entry_destroy(e); \
+ for (; e != end; ++e) if (*hx++) ctype##_##X##_entry_del(e); \
} \
\
- STC_API void ctype##_##X##_destroy(ctype##_##X* self) { \
+ STC_API void ctype##_##X##_del(ctype##_##X* self) { \
ctype##_##X##_wipe_(self); \
free(self->_hashx); \
free(self->table); \
@@ -423,7 +423,7 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t;
size_t i = chash_entry_index(*self, get), j = i, k, cap = self->bucket_count; \
ctype##_##X##_value_t* slot = self->table; \
uint8_t* hashx = self->_hashx; \
- ctype##_##X##_entry_destroy(&slot[i]); \
+ ctype##_##X##_entry_del(&slot[i]); \
do { /* deletion from hash table without tombstone */ \
if (++j == cap) j = 0; /* ++j; j %= cap; is slow */ \
if (! hashx[j]) \
diff --git a/stc/coption.h b/stc/coption.h
index 4b0712d6..fe961ad9 100644
--- a/stc/coption.h
+++ b/stc/coption.h
@@ -43,7 +43,7 @@ Example:
const char* optstr = "xy:z::123";
printf("program -x -y ARG -z [ARG] -1 -2 -3 --foo --bar ARG --opt [ARG] [ARGUMENTS]\n");
int c;
- coption_t opt = coption_ini;
+ coption_t opt = coption_INIT;
while ((c = coption_get(&opt, argc, argv, optstr, longopts)) != -1) {
switch (c) {
case '?': printf("error: unknown option: %s\n", opt.faulty); break;
@@ -83,7 +83,7 @@ typedef struct {
int val;
} coption_long_t;
-static const coption_t coption_ini = {1, 0, NULL, NULL, -1, 1, 0, 0, {'-', '?', '\0'}};
+static const coption_t coption_INIT = {1, 0, NULL, NULL, -1, 1, 0, 0, {'-', '?', '\0'}};
static void _coption_permute(char *argv[], int j, int n) { /* move argv[j] over n elements to the left */
int k;
@@ -93,7 +93,7 @@ static void _coption_permute(char *argv[], int j, int n) { /* move argv[j] over
argv[j - k] = p;
}
-/* @param opt output; must be initialized to coption_ini on first call
+/* @param opt output; must be initialized to coption_INIT on first call
* @return ASCII val for a short option; longopt.val for a long option;
* -1 if argv[] is fully processed; '?' for an unknown option or
* an ambiguous long option; ':' if an option argument is missing
diff --git a/stc/cpqueue.h b/stc/cpqueue.h
index 03fe09d2..4241cc32 100644
--- a/stc/cpqueue.h
+++ b/stc/cpqueue.h
@@ -41,7 +41,7 @@
printf("%f ", *cpqueue_f_top(queue));
cpqueue_f_pop(&queue);
}
- cpqueue_f_destroy(&queue);
+ cpqueue_f_del(&queue);
}
*/
@@ -63,7 +63,7 @@
STC_INLINE bool \
cpqueue_##X##_empty(cpqueue_##X pq) {return ctype##_empty(pq);} \
STC_INLINE void \
- cpqueue_##X##_destroy(cpqueue_##X* self) {ctype##_destroy(self);} \
+ cpqueue_##X##_del(cpqueue_##X* self) {ctype##_del(self);} \
STC_API void \
cpqueue_##X##_build(cpqueue_##X* self); \
STC_API void \
diff --git a/stc/cqueue.h b/stc/cqueue.h
index 4a13c335..27346de6 100644
--- a/stc/cqueue.h
+++ b/stc/cqueue.h
@@ -49,7 +49,7 @@
--n, cqueue_i_pop(&queue);
}
printf("%d\n", n);
- cqueue_i_destroy(&queue);
+ cqueue_i_del(&queue);
}
*/
@@ -67,7 +67,7 @@
STC_INLINE cqueue_##X \
cqueue_##X##_init() {return ctype##_init();} \
STC_INLINE void \
- cqueue_##X##_destroy(cqueue_##X* self) {ctype##_destroy(self);} \
+ cqueue_##X##_del(cqueue_##X* self) {ctype##_del(self);} \
STC_INLINE size_t \
cqueue_##X##_size(cqueue_##X pq) {return ctype##_size(pq);} \
STC_INLINE bool \
diff --git a/stc/cstack.h b/stc/cstack.h
index 0d914445..0351a545 100644
--- a/stc/cstack.h
+++ b/stc/cstack.h
@@ -56,7 +56,7 @@
STC_INLINE cstack_##X \
cstack_##X##_init() {return ctype##_init();} \
STC_INLINE void \
- cstack_##X##_destroy(cstack_##X* self) {ctype##_destroy(self);} \
+ cstack_##X##_del(cstack_##X* self) {ctype##_del(self);} \
STC_INLINE size_t \
cstack_##X##_size(cstack_##X pq) {return ctype##_size(pq);} \
STC_INLINE bool \
diff --git a/stc/cstr.h b/stc/cstr.h
index 351e1beb..bb64bf5c 100644
--- a/stc/cstr.h
+++ b/stc/cstr.h
@@ -35,11 +35,11 @@ typedef char cstr_value_t;
static size_t _cstr_nullrep[] = {0, 0, 0};
-static cstr_t cstr_ini = {(char* ) &_cstr_nullrep[2]};
+static cstr_t cstr_INIT = {(char* ) &_cstr_nullrep[2]};
#define cstr_size(s) ((const size_t *) (s).str)[-2]
#define cstr_capacity(s) ((const size_t *) (s).str)[-1]
#define cstr_empty(s) (cstr_size(s) == 0)
-#define cstr_npos ((size_t) (-1))
+#define cstr_NPOS ((size_t) (-1))
STC_API cstr_t
cstr_n(const char* str, size_t len);
@@ -68,23 +68,23 @@ c_strnstr(const char* s, const char* needle, size_t n);
#define _cstr_cap(size) ((((size) + 24) >> 4) * 16 - 9)
STC_INLINE cstr_t
-cstr_init() {return cstr_ini;}
+cstr_init() {return cstr_INIT;}
STC_INLINE void
-cstr_destroy(cstr_t* self) {
+cstr_del(cstr_t* self) {
if (cstr_capacity(*self))
free(_cstr_rep(self));
}
STC_INLINE cstr_t
cstr_with_capacity(size_t cap) {
- cstr_t s = cstr_ini;
+ cstr_t s = cstr_INIT;
cstr_reserve(&s, cap);
return s;
}
STC_INLINE cstr_t
cstr_with_size(size_t len, char fill) {
- cstr_t s = cstr_ini;
+ cstr_t s = cstr_INIT;
cstr_resize(&s, len, fill);
return s;
}
@@ -132,7 +132,7 @@ cstr_take(cstr_t* self, cstr_t s) {
STC_INLINE cstr_t
cstr_move(cstr_t* self) {
cstr_t tmp = *self;
- *self = cstr_ini;
+ *self = cstr_INIT;
return tmp;
}
@@ -180,12 +180,12 @@ cstr_compare(const cstr_t *s1, const cstr_t *s2) {
STC_INLINE size_t
cstr_find_n(const cstr_t* s, const char* needle, size_t pos, size_t n) {
char* res = c_strnstr(s->str + pos, needle, n);
- return res ? res - s->str : cstr_npos;
+ return res ? res - s->str : cstr_NPOS;
}
STC_INLINE size_t
cstr_find(const cstr_t* s, const char* needle) {
char* res = strstr(s->str, needle);
- return res ? res - s->str : cstr_npos;
+ return res ? res - s->str : cstr_NPOS;
}
/* cvec/cmap API functions: */
@@ -229,7 +229,7 @@ cstr_resize(cstr_t* self, size_t len, char fill) {
STC_API cstr_t
cstr_n(const char* str, size_t len) {
- if (len == 0) return cstr_ini;
+ if (len == 0) return cstr_INIT;
size_t *rep = (size_t *) malloc(_cstr_mem(len));
cstr_t s = {(char *) memcpy(rep + 2, str, len)};
s.str[rep[0] = len] = '\0';
@@ -246,7 +246,7 @@ cstr_from(const char* fmt, ...) {
# pragma warning(push)
# pragma warning(disable: 4996)
#endif
- cstr_t tmp = cstr_ini;
+ cstr_t tmp = cstr_INIT;
va_list args, args2;
va_start(args, fmt);
va_copy(args2, args);
diff --git a/stc/cvec.h b/stc/cvec.h
index 6f292b33..f3c203ca 100644
--- a/stc/cvec.h
+++ b/stc/cvec.h
@@ -27,20 +27,20 @@
#include <string.h>
#include "cdefs.h"
-#define cvec_ini {NULL}
+#define cvec_INIT {NULL}
#define cvec_size(v) _cvec_safe_size((v).data)
#define cvec_capacity(v) _cvec_safe_capacity((v).data)
#define cvec_empty(v) (cvec_size(v) == 0)
#define using_cvec(...) c_MACRO_OVERLOAD(using_cvec, __VA_ARGS__)
#define using_cvec_2(X, Value) \
- using_cvec_3(X, Value, c_default_destroy)
+ using_cvec_3(X, Value, c_default_del)
#define using_cvec_3(X, Value, valueDestroy) \
using_cvec_4(X, Value, valueDestroy, c_default_compare)
#define using_cvec_4(X, Value, valueDestroy, valueCompare) \
using_cvec_7(X, Value, valueDestroy, valueCompare, Value, c_default_to_raw, c_default_from_raw)
#define using_cvec_str() \
- using_cvec_7(str, cstr_t, cstr_destroy, cstr_compare_raw, const char*, cstr_to_raw, cstr)
+ using_cvec_7(str, cstr_t, cstr_del, cstr_compare_raw, const char*, cstr_to_raw, cstr)
#define using_cvec_7(X, Value, valueDestroy, valueCompareRaw, RawValue, valueToRaw, valueFromRaw) \
@@ -55,7 +55,7 @@
} cvec_##X; \
\
STC_INLINE cvec_##X \
- cvec_##X##_init(void) {cvec_##X v = cvec_ini; return v;} \
+ cvec_##X##_init(void) {cvec_##X v = cvec_INIT; return v;} \
STC_INLINE bool \
cvec_##X##_empty(cvec_##X v) {return cvec_empty(v);} \
STC_INLINE size_t \
@@ -67,7 +67,7 @@
STC_INLINE void \
cvec_##X##_clear(cvec_##X* self); \
STC_API void \
- cvec_##X##_destroy(cvec_##X* self); \
+ cvec_##X##_del(cvec_##X* self); \
STC_API void \
cvec_##X##_reserve(cvec_##X* self, size_t cap); \
STC_API void \
@@ -77,13 +77,13 @@
\
STC_INLINE cvec_##X \
cvec_##X##_with_size(size_t size, Value null_val) { \
- cvec_##X x = cvec_ini; \
+ cvec_##X x = cvec_INIT; \
cvec_##X##_resize(&x, size, null_val); \
return x; \
} \
STC_INLINE cvec_##X \
cvec_##X##_with_capacity(size_t size) { \
- cvec_##X x = cvec_ini; \
+ cvec_##X x = cvec_INIT; \
cvec_##X##_reserve(&x, size); \
return x; \
} \
@@ -208,7 +208,7 @@
} \
} \
STC_API void \
- cvec_##X##_destroy(cvec_##X* self) { \
+ cvec_##X##_del(cvec_##X* self) { \
cvec_##X##_clear(self); \
if (self->data) free(_cvec_alloced(self->data)); \
} \