summaryrefslogtreecommitdiffhomepage
path: root/examples/README.md
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 /examples/README.md
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 'examples/README.md')
-rw-r--r--examples/README.md16
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/README.md b/examples/README.md
index 95880385..74ac4384 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -39,9 +39,9 @@ typedef struct Viking {
} Viking;
-void viking_destroy(Viking* vk) {
- cstr_destroy(&vk->name);
- cstr_destroy(&vk->country);
+void viking_del(Viking* vk) {
+ cstr_del(&vk->name);
+ cstr_del(&vk->country);
}
static inline VikingVw viking_toVw(Viking* vk) {
@@ -53,14 +53,14 @@ static inline Viking viking_fromVw(VikingVw vw) { // note: parameter is by value
```
With this in place, we use the full using_cmap() macro to define {Viking -> int} hash map type:
```
-using_cmap(vk, Viking, int, c_default_destroy, vikingvw_equals, vikingvw_hash,
- viking_destroy, VikingVw, viking_toVw, viking_fromVw);
+using_cmap(vk, Viking, int, c_default_del, vikingvw_equals, vikingvw_hash,
+ viking_del, VikingVw, viking_toVw, viking_fromVw);
```
-cmap_vk uses vikingvw_hash() for hash value calculations, and vikingvw_equals() for equality test. cmap_vk_destroy() will free all memory allocated for Viking keys and the hash table values.
+cmap_vk uses vikingvw_hash() for hash value calculations, and vikingvw_equals() for equality test. cmap_vk_del() will free all memory allocated for Viking keys and the hash table values.
Finally, main which also demos the generic c_push_items() of multiple elements:
```
int main() {
- cmap_vk vikings = cmap_ini;
+ cmap_vk vikings = cmap_INIT;
c_push_items(&vikings, cmap_vk, {
{ {"Einar", "Norway"}, 20 },
{ {"Olaf", "Denmark"}, 24 },
@@ -74,6 +74,6 @@ int main() {
c_foreach (k, cmap_vk, vikings) {
printf("%s of %s has %d hp\n", k.get->key.name.str, k.get->key.country.str, k.get->value);
}
- cmap_vk_destroy(&vikings);
+ cmap_vk_del(&vikings);
}
```