diff options
Diffstat (limited to 'examples/README.md')
| -rw-r--r-- | examples/README.md | 16 |
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);
}
```
|
