summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/arc_containers.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-03-26 00:27:45 +0100
committerTyge Løvset <[email protected]>2023-03-26 00:27:45 +0100
commiteb85069b669e754836b9d4587ba03d3af1a5e975 (patch)
tree45c9a0d3fe40c59a8b33ae8ecd2e7aa78bef6240 /misc/examples/arc_containers.c
parente8be14dfc894eeac859f0287d4d5b4f4745c0585 (diff)
downloadSTC-modified-eb85069b669e754836b9d4587ba03d3af1a5e975.tar.gz
STC-modified-eb85069b669e754836b9d4587ba03d3af1a5e975.zip
development branch for 4.2
Removed uses of c_auto and c_with in documentation examples and code examples. Still using c_defer a few places. Renamed c11/fmt.h to c11/print.h. Some additions in ccommon.h, e.g. c_const_cast(T, x). Improved docs.
Diffstat (limited to 'misc/examples/arc_containers.c')
-rw-r--r--misc/examples/arc_containers.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/misc/examples/arc_containers.c b/misc/examples/arc_containers.c
index b621c386..84ba8dda 100644
--- a/misc/examples/arc_containers.c
+++ b/misc/examples/arc_containers.c
@@ -27,9 +27,12 @@
int main()
{
- c_auto (Stack, stack)
- c_auto (List, list)
- {
+ Stack stack = {0};
+ List list = {0};
+ c_defer(
+ Stack_drop(&stack),
+ List_drop(&list)
+ ){
// POPULATE stack with shared pointers to Maps:
Map *map;
map = Stack_push(&stack, Arc_from(Map_init()))->get;
@@ -62,13 +65,13 @@ int main()
// Add one more element to the shared map:
Map_emplace_or_assign(stack.data[1].get, "SHARED", 2021);
-
puts("STACKS");
c_foreach (i, Stack, stack) {
c_forpair (name, year, Map, *i.ref->get)
printf(" %s:%d", cstr_str(_.name), *_.year);
puts("");
}
+
puts("LIST");
c_foreach (i, List, list) {
c_forpair (name, year, Map, *i.ref->get)