summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-08-05 09:20:47 +0200
committerTyge Løvset <[email protected]>2022-08-05 09:20:47 +0200
commit94f94957919292b572ea74a30dab5305eaf64808 (patch)
tree6026ca73187454f374dd348ab59502025bf013d6 /examples
parentf738106b75d9c4d7998294ffac9ee43f04e18667 (diff)
downloadSTC-modified-94f94957919292b572ea74a30dab5305eaf64808.tar.gz
STC-modified-94f94957919292b572ea74a30dab5305eaf64808.zip
Reduce usage of c_apply() macro.
Diffstat (limited to 'examples')
-rw-r--r--examples/arc_containers.c19
-rw-r--r--examples/box.c4
-rw-r--r--examples/inits.c4
-rw-r--r--examples/regex2.c2
4 files changed, 15 insertions, 14 deletions
diff --git a/examples/arc_containers.c b/examples/arc_containers.c
index 969825eb..e8716129 100644
--- a/examples/arc_containers.c
+++ b/examples/arc_containers.c
@@ -32,19 +32,20 @@ int main()
// POPULATE stack with shared pointers to Maps:
Map *map;
map = Stack_push(&stack, Arc_make(Map_init()))->get;
- c_apply(v, Map_emplace(map, c_pair(v)), Map_raw, {
- {"Joey", 1990}, {"Mary", 1995}, {"Joanna", 1992}
- });
+ Map_emplace(map, "Joey", 1990);
+ Map_emplace(map, "Mary", 1995);
+ Map_emplace(map, "Joanna", 1992);
+
map = Stack_push(&stack, Arc_make(Map_init()))->get;
- c_apply(v, Map_emplace(map, c_pair(v)), Map_raw, {
- {"Rosanna", 2001}, {"Brad", 1999}, {"Jack", 1980}
- });
+ Map_emplace(map, "Rosanna", 2001);
+ Map_emplace(map, "Brad", 1999);
+ Map_emplace(map, "Jack", 1980);
// POPULATE list:
map = List_push_back(&list, Arc_make(Map_init()))->get;
- c_apply(v, Map_emplace(map, c_pair(v)), Map_raw, {
- {"Steve", 1979}, {"Rick", 1974}, {"Tracy", 2003}
- });
+ Map_emplace(map, "Steve", 1979);
+ Map_emplace(map, "Rick", 1974);
+ Map_emplace(map, "Tracy", 2003);
// Share two Maps from the stack with the list using emplace (clone the carc):
List_push_back(&list, Arc_clone(stack.data[0]));
diff --git a/examples/box.c b/examples/box.c
index ef2ff28b..c7e649bf 100644
--- a/examples/box.c
+++ b/examples/box.c
@@ -41,7 +41,6 @@ int main()
c_auto (PBox, p, q)
{
p = PBox_make(Person_new("Laura", "Palmer"));
-
q = PBox_clone(p);
cstr_assign(&q.get->name, "Leland");
@@ -52,7 +51,8 @@ int main()
Persons_push(&vec, PBox_make(Person_new("Audrey", "Home")));
// NB! Clone p and q to the vector using emplace_back()
- c_apply(v, Persons_push(&vec, PBox_clone(*v)), PBox, {p, q});
+ Persons_push(&vec, PBox_clone(p));
+ Persons_push(&vec, PBox_clone(q));
c_foreach (i, Persons, vec)
printf("%s %s\n", cstr_str(&i.ref->get->name), cstr_str(&i.ref->get->last));
diff --git a/examples/inits.c b/examples/inits.c
index 608dd146..a2fb51cb 100644
--- a/examples/inits.c
+++ b/examples/inits.c
@@ -40,8 +40,8 @@ int main(void)
const float nums[] = {4.0f, 2.0f, 5.0f, 3.0f, 1.0f};
// PRIORITY QUEUE
-
- c_apply_array(v, cpque_f_push(&floats, *v), const float, nums, c_arraylen(nums));
+ c_forrange (i, c_arraylen(nums))
+ cpque_f_push(&floats, nums[i]);
puts("\npop and show high priorites first:");
while (! cpque_f_empty(&floats)) {
diff --git a/examples/regex2.c b/examples/regex2.c
index 672020f6..30602444 100644
--- a/examples/regex2.c
+++ b/examples/regex2.c
@@ -26,7 +26,7 @@ int main()
c_foreach_match (j, &re, s[i].input) {
c_forrange (k, cregex_captures(&re))
- printf(" submatch %d: %.*s\n", k, c_ARGsv(j.ref[k]));
+ printf(" submatch %d: %.*s\n", (int)k, c_ARGsv(j.ref[k]));
puts("");
}
}