summaryrefslogtreecommitdiffhomepage
path: root/examples/advanced.c
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/advanced.c
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/advanced.c')
-rw-r--r--examples/advanced.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/advanced.c b/examples/advanced.c
index 200ab5a3..7cf55d2c 100644
--- a/examples/advanced.c
+++ b/examples/advanced.c
@@ -22,9 +22,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);
}
// Viking view struct -----------------------
@@ -51,17 +51,17 @@ Viking viking_fromVw(VikingVw vw) {
}
// Using 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_del() will free all memory allocated for Viking keys and the hash table values.
// Main ----------------------------
int main()
{
- cmap_vk vikings = cmap_ini;
+ cmap_vk vikings = cmap_INIT;
c_push_items(&vikings, cmap_vk, {
{{"Einar", "Norway"}, 20},
{{"Olaf", "Denmark"}, 24},
@@ -76,6 +76,6 @@ int main()
c_foreach (k, cmap_vk, vikings) {
printf("%s of %s has %d hp\n", k.get->first.name.str, k.get->first.country.str, k.get->second);
}
- cmap_vk_destroy(&vikings);
+ cmap_vk_del(&vikings);
}