From e9c30e66af9c5c3054735eeb65c0bb384dea96b4 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Sat, 7 May 2022 16:38:58 +0200 Subject: Updated alt/csmap.h to be synced with current csmap.h; alt-version allocates each node separately on the heap, regular uses an array. Now alt-version of csmap and cstr can be used by defining -DSTC_CSMAP_V1 and -DSTC_CSTR_V1 when compiling. Improved code readability by making line breaks after if and while (also cmap.h). Note, the alt-versions may be removed in the future, but the alt csmap.h may be made into an intrusive sorted map, where the creation and destruction of nodes must be done by the user. --- examples/make.sh | 2 +- examples/sso_substr.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/make.sh b/examples/make.sh index 4a4fdbcf..facdedc1 100644 --- a/examples/make.sh +++ b/examples/make.sh @@ -1,9 +1,9 @@ #!/bin/bash cc='gcc -s -O2 -Wall -std=c99 -pedantic' #cc='clang -s -O2 -Wall -std=c99 -pedantic' +#cc='clang -s -O2 -Wall -std=c99 -pedantic -DSTC_CSTR_V1 -DSTC_CSMAP_V1' #cc='gcc -x c++ -s -O2 -Wall -std=c++20' #cc='g++ -x c++ -s -O2 -Wall' -#cc='clang -s -O2 -Wall -std=c99 -pedantic -DSTC_OLD_CSTR' #cc='clang' #cc='clang -c -DSTC_HEADER' #cc='cl -O2 -nologo -W2 -MD' diff --git a/examples/sso_substr.c b/examples/sso_substr.c index fdb53d0b..f8382f16 100644 --- a/examples/sso_substr.c +++ b/examples/sso_substr.c @@ -14,8 +14,9 @@ int main () cstr_assign(&str, "apples are green or red"); cstr s2 = cstr_from_sv(cstr_substr(&str, -3, 3)); // "red" cstr s3 = cstr_from_sv(cstr_substr(&str, 0, 6)); // "apples" + #ifndef STC_CSTR_V1 printf("%s %s: %d, %d\n", cstr_str(&s2), cstr_str(&s3), cstr_is_long(&str), cstr_is_long(&s2)); - + #endif c_drop (cstr, &str, &s2, &s3); } -- cgit v1.2.3