diff options
| author | Tyge Lovset <[email protected]> | 2021-08-29 10:41:06 +0200 |
|---|---|---|
| committer | Tyge Lovset <[email protected]> | 2021-08-29 10:41:06 +0200 |
| commit | 6371e122b2447f08c8d8859b3530d79be1831f10 (patch) | |
| tree | 213999839b3ad7653654019f3faf4d568b2b4b7e | |
| parent | 28bf4ac92625b2ec7c4ddade9c14a4363ebd2681 (diff) | |
| download | STC-modified-6371e122b2447f08c8d8859b3530d79be1831f10.tar.gz STC-modified-6371e122b2447f08c8d8859b3530d79be1831f10.zip | |
Replaced cstr_toraw (deprecated) with cstr_str used to convert from cstr to const char*.
| -rw-r--r-- | benchmarks/others/clist_v1.h | 2 | ||||
| -rw-r--r-- | benchmarks/others/csmap_v1.h | 8 | ||||
| -rw-r--r-- | docs/cdeq_api.md | 2 | ||||
| -rw-r--r-- | docs/clist_api.md | 2 | ||||
| -rw-r--r-- | docs/cstr_api.md | 4 | ||||
| -rw-r--r-- | docs/cvec_api.md | 2 | ||||
| -rw-r--r-- | include/stc/cdeq.h | 2 | ||||
| -rw-r--r-- | include/stc/clist.h | 2 | ||||
| -rw-r--r-- | include/stc/cmap.h | 8 | ||||
| -rw-r--r-- | include/stc/csmap.h | 8 | ||||
| -rw-r--r-- | include/stc/cstr.h | 2 | ||||
| -rw-r--r-- | include/stc/cvec.h | 2 |
12 files changed, 22 insertions, 22 deletions
diff --git a/benchmarks/others/clist_v1.h b/benchmarks/others/clist_v1.h index 00e04e9b..0dd8feef 100644 --- a/benchmarks/others/clist_v1.h +++ b/benchmarks/others/clist_v1.h @@ -69,7 +69,7 @@ _c_using_clist(clist_##X, Value, valueCompare, valueDel, valueFromRaw, valueToRaw, RawValue)
#define using_clist_str() \
- _c_using_clist(clist_str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_toraw, const char*)
+ _c_using_clist(clist_str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_str, const char*)
#define _c_using_clist_types(CX, Value) \
diff --git a/benchmarks/others/csmap_v1.h b/benchmarks/others/csmap_v1.h index 14114150..69f3f06d 100644 --- a/benchmarks/others/csmap_v1.h +++ b/benchmarks/others/csmap_v1.h @@ -87,8 +87,8 @@ int main(void) { #define using_csmap_str() \
_c_using_aatree(csmap_str, csmap_, cstr, cstr, c_rawstr_compare, \
- cstr_del, cstr_from, cstr_toraw, const char*, \
- cstr_del, cstr_from, cstr_toraw, const char*)
+ cstr_del, cstr_from, cstr_str, const char*, \
+ cstr_del, cstr_from, cstr_str, const char*)
#define using_csmap_strkey(...) c_MACRO_OVERLOAD(using_csmap_strkey, __VA_ARGS__)
@@ -105,7 +105,7 @@ int main(void) { #define _c_using_aatree_strkey(X, C, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped) \
_c_using_aatree(C##X, C, cstr, Mapped, c_rawstr_compare, \
mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \
- cstr_del, cstr_from, cstr_toraw, const char*)
+ cstr_del, cstr_from, cstr_str, const char*)
#define using_csmap_strval(...) c_MACRO_OVERLOAD(using_csmap_strval, __VA_ARGS__)
@@ -121,7 +121,7 @@ int main(void) { #define using_csmap_strval_7(X, Key, keyCompareRaw, keyDel, keyFromRaw, keyToRaw, RawKey) \
_c_using_aatree(csmap_##X, csmap_, Key, cstr, keyCompareRaw, \
- cstr_del, cstr_from, cstr_toraw, const char*, \
+ cstr_del, cstr_from, cstr_str, const char*, \
keyDel, keyFromRaw, keyToRaw, RawKey)
#define SET_ONLY_csmap_(...)
diff --git a/docs/cdeq_api.md b/docs/cdeq_api.md index 42e46240..83c0f19f 100644 --- a/docs/cdeq_api.md +++ b/docs/cdeq_api.md @@ -23,7 +23,7 @@ be replaced by `i` in all of the following documentation. `using_cdeq_str()` is a shorthand for: ``` -using_cdeq(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_toraw, const char*) +using_cdeq(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_str, const char*) ``` ## Methods diff --git a/docs/clist_api.md b/docs/clist_api.md index 2028e764..b57662ca 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -35,7 +35,7 @@ The macro `using_clist()` must be instantiated in the global scope. `X` is a typ will affect the names of all clist types and methods. E.g. declaring `using_clist(i, int);`, `X` should be replaced by `i` in all of the following documentation. `using_clist_str()` is a shorthand for ```c -using_clist(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_toraw, const char*) +using_clist(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_str, const char*) ``` ## Methods diff --git a/docs/cstr_api.md b/docs/cstr_api.md index 1acceec2..fd2b241f 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -28,6 +28,8 @@ cstr* cstr_take(cstr* self, cstr s); // take th cstr cstr_move(cstr* self); // move string to caller, leave empty string void cstr_del(cstr *self); // destructor +const char* cstr_str(const cstr* self); // self->str +char* cstr_data(cstr* self); // self->str size_t cstr_size(cstr s); size_t cstr_length(cstr s); size_t cstr_capacity(cstr s); @@ -89,8 +91,6 @@ Note that all methods with arguments `(..., const char* str, size_t n)`, `n` mus #### Helper methods: ```c -const char* cstr_toraw(const cstr* self); - int cstr_compare(const cstr *s1, const cstr *s2); bool cstr_equals(const cstr *s1, const cstr *s2); bool cstr_hash(const cstr *s, ...); diff --git a/docs/cvec_api.md b/docs/cvec_api.md index 016d82e3..5a98b9ca 100644 --- a/docs/cvec_api.md +++ b/docs/cvec_api.md @@ -27,7 +27,7 @@ be replaced by `i` in all of the following documentation. `using_cvec_str()` is a shorthand for: ``` -using_cvec(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_toraw, const char*) +using_cvec(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_str, const char*) ``` ## Methods diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index 49de8662..d052e9eb 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -45,7 +45,7 @@ _c_using_cdeq(cdeq_##X, Value, valueCompareRaw, valueDel, valueFromRaw, valueToRaw, RawValue, defTypes)
#define using_cdeq_str() \
- using_cdeq_7(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_toraw, const char*)
+ using_cdeq_7(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_str, const char*)
struct cdeq_rep { size_t size, cap; void* base[]; };
diff --git a/include/stc/clist.h b/include/stc/clist.h index 4166fffe..75364a4f 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -74,7 +74,7 @@ _c_using_clist(clist_##X, Value, valueCompareRaw, valueDel, valueFromRaw, valueToRaw, RawValue, defTypes)
#define using_clist_str() \
- using_clist_7(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_toraw, const char*)
+ using_clist_7(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_str, const char*)
#define _c_clist_types(CX, Value) \
diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 89975374..1f9401d3 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -90,8 +90,8 @@ int main(void) { #define using_cmap_str() \
_c_using_chash(cmap_str, cmap_, cstr, cstr, c_rawstr_equals, c_rawstr_hash, \
- cstr_del, cstr_from, cstr_toraw, const char*, c_true, \
- cstr_del, cstr_from, cstr_toraw, const char*)
+ cstr_del, cstr_from, cstr_str, const char*, c_true, \
+ cstr_del, cstr_from, cstr_str, const char*)
#define using_cmap_strkey(...) c_MACRO_OVERLOAD(using_cmap_strkey, __VA_ARGS__)
@@ -107,7 +107,7 @@ int main(void) { #define _c_using_chash_strkey(X, C, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes) \
_c_using_chash(C##X, C, cstr, Mapped, c_rawstr_equals, c_rawstr_hash, \
mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
- cstr_del, cstr_from, cstr_toraw, const char*)
+ cstr_del, cstr_from, cstr_str, const char*)
#define using_cmap_strval(...) c_MACRO_OVERLOAD(using_cmap_strval, __VA_ARGS__)
@@ -122,7 +122,7 @@ int main(void) { using_cmap_strval_9(X, Key, keyEquals, keyHash, keyDel, keyClone, c_default_toraw, Key, c_true)
#define using_cmap_strval_9(X, Key, keyEqualsRaw, keyHashRaw, keyDel, keyFromRaw, keyToRaw, RawKey, defTypes) \
_c_using_chash(cmap_##X, cmap_, Key, cstr, keyEqualsRaw, keyHashRaw, \
- cstr_del, cstr_from, cstr_toraw, const char*, defTypes, \
+ cstr_del, cstr_from, cstr_str, const char*, defTypes, \
keyDel, keyFromRaw, keyToRaw, RawKey)
#define SET_ONLY_cmap_(...)
diff --git a/include/stc/csmap.h b/include/stc/csmap.h index b61af839..9db002a4 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -87,8 +87,8 @@ int main(void) { #define using_csmap_str() \
_c_using_aatree(csmap_str, csmap_, cstr, cstr, c_rawstr_compare, \
- cstr_del, cstr_from, cstr_toraw, const char*, c_true, \
- cstr_del, cstr_from, cstr_toraw, const char*)
+ cstr_del, cstr_from, cstr_str, const char*, c_true, \
+ cstr_del, cstr_from, cstr_str, const char*)
#define using_csmap_strkey(...) c_MACRO_OVERLOAD(using_csmap_strkey, __VA_ARGS__)
@@ -104,7 +104,7 @@ int main(void) { #define _c_using_aatree_strkey(X, C, Mapped, mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes) \
_c_using_aatree(C##X, C, cstr, Mapped, c_rawstr_compare, \
mappedDel, mappedFromRaw, mappedToRaw, RawMapped, defTypes, \
- cstr_del, cstr_from, cstr_toraw, const char*)
+ cstr_del, cstr_from, cstr_str, const char*)
#define using_csmap_strval(...) c_MACRO_OVERLOAD(using_csmap_strval, __VA_ARGS__)
@@ -119,7 +119,7 @@ int main(void) { using_csmap_strval_8(X, Key, keyCompare, keyDel, keyClone, c_default_toraw, Key, c_true)
#define using_csmap_strval_8(X, Key, keyCompareRaw, keyDel, keyFromRaw, keyToRaw, RawKey, defTypes) \
_c_using_aatree(csmap_##X, csmap_, Key, cstr, keyCompareRaw, \
- cstr_del, cstr_from, cstr_toraw, const char*, defTypes, \
+ cstr_del, cstr_from, cstr_str, const char*, defTypes, \
keyDel, keyFromRaw, keyToRaw, RawKey)
#define SET_ONLY_csmap_(...)
diff --git a/include/stc/cstr.h b/include/stc/cstr.h index e7af71f3..67f1a0a5 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -185,7 +185,7 @@ cstr_iends_with(cstr s, const char* sub) { }
/* container adaptor functions: */
-#define cstr_toraw(xp) ((xp)->str)
+#define cstr_toraw(xp) ((xp)->str) // deprecated
#define cstr_compare(xp, yp) strcmp((xp)->str, (yp)->str)
#define cstr_equals(xp, yp) (strcmp((xp)->str, (yp)->str) == 0)
#define cstr_hash(xp, ...) c_default_hash((xp)->str, cstr_size(*(xp)))
diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 75a8008b..567c22ae 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -45,7 +45,7 @@ _c_using_cvec(cvec_##X, Value, valueCompareRaw, valueDel, valueFromRaw, valueToRaw, RawValue, defTypes)
#define using_cvec_str() \
- using_cvec_7(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_toraw, const char*)
+ using_cvec_7(str, cstr, c_rawstr_compare, cstr_del, cstr_from, cstr_str, const char*)
struct cvec_rep { size_t size, cap; void* data[]; };
#define _cvec_rep(self) c_container_of((self)->data, struct cvec_rep, data)
|
