diff options
| author | Tyge Løvset <[email protected]> | 2022-03-26 16:21:39 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-03-26 16:21:39 +0100 |
| commit | 920a55280a28ce38b98045f797067e285395bb6e (patch) | |
| tree | d3afd64cf8ae1270324c82391bafbd9413e49749 /examples | |
| parent | f943c8b7a6e46dc002ffc63c9fbcc111f6dca55d (diff) | |
| download | STC-modified-920a55280a28ce38b98045f797067e285395bb6e.tar.gz STC-modified-920a55280a28ce38b98045f797067e285395bb6e.zip | |
Fixed alt/cstr.h (short string optimized), so that it can be used in containers. Had to change some API in csview to make it play with that.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/sso_map.c | 19 | ||||
| -rw-r--r-- | examples/utf8replace_c.c | 2 |
2 files changed, 20 insertions, 1 deletions
diff --git a/examples/sso_map.c b/examples/sso_map.c new file mode 100644 index 00000000..6022572f --- /dev/null +++ b/examples/sso_map.c @@ -0,0 +1,19 @@ +#include <stc/alt/cstr.h>
+
+#define i_key_str
+#define i_val_str
+#include <stc/cmap.h>
+
+
+int main()
+{
+ c_auto (cmap_str, m) {
+ cmap_str_emplace(&m, "Test short", "This is a short string.");
+ cmap_str_emplace(&m, "Test long ", "This is a longer string.");
+
+ c_forpair (k, v, cmap_str, m)
+ printf("%s: '%s' Len=%" PRIuMAX ", Is long: %s\n",
+ cstr_str(&_.k), cstr_str(&_.v), cstr_size(_.v),
+ cstr_is_long(&_.v)?"true":"false");
+ }
+}
diff --git a/examples/utf8replace_c.c b/examples/utf8replace_c.c index e04f2cb8..49680ecd 100644 --- a/examples/utf8replace_c.c +++ b/examples/utf8replace_c.c @@ -14,7 +14,7 @@ int main() { ); printf("%s\n", hello.str); - csview sv = csview_from_s(hello); + csview sv = csview_from_s(&hello); c_foreach (c, csview, sv) printf(c_PRIsv ",", c_ARGsv(c.codep)); } |
