summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-11-03 11:30:06 +0100
committerTyge Løvset <[email protected]>2021-11-03 11:30:06 +0100
commite259ed7807dd9474cc94ba625db4dcd573431362 (patch)
tree0e83bf2d49a1f0ec43f9e9b0b74c69ef4fd97a1b /examples
parent73b1ed7c17b94647438c7e73738bf0820e5d57ad (diff)
downloadSTC-modified-e259ed7807dd9474cc94ba625db4dcd573431362.tar.gz
STC-modified-e259ed7807dd9474cc94ba625db4dcd573431362.zip
Changed container_X_get() and container_X_at() to return const value* (or const mapped*). Added container_X_getmut() for mutable version. Updated docs.
Diffstat (limited to 'examples')
-rw-r--r--examples/astar.c2
-rw-r--r--examples/mapmap.c2
-rw-r--r--examples/stack.c5
3 files changed, 4 insertions, 5 deletions
diff --git a/examples/astar.c b/examples/astar.c
index 04c18113..7410de96 100644
--- a/examples/astar.c
+++ b/examples/astar.c
@@ -107,7 +107,7 @@ astar(cstr* maze, int width)
int new_cost = *csmap_pcost_at(&costs, current);
if (maze->str[point_index(&next)] != '#')
{
- csmap_pcost_value *cost = csmap_pcost_get(&costs, next);
+ const csmap_pcost_value *cost = csmap_pcost_get(&costs, next);
if (cost == NULL || new_cost < cost->second)
{
csmap_pcost_insert(&costs, next, new_cost);
diff --git a/examples/mapmap.c b/examples/mapmap.c
index 047132d1..73a00861 100644
--- a/examples/mapmap.c
+++ b/examples/mapmap.c
@@ -19,7 +19,7 @@ void add(csmap_conf* map, const char* section, const char* entry, const char* va
bool contains(csmap_conf* map, const char* section, const char* entry)
{
- csmap_conf_value *val = csmap_conf_get(map, section);
+ const csmap_conf_value *val = csmap_conf_get(map, section);
return val && csmap_sect_get(&val->second, entry);
}
diff --git a/examples/stack.c b/examples/stack.c
index 54d5aeed..dac0112e 100644
--- a/examples/stack.c
+++ b/examples/stack.c
@@ -11,9 +11,8 @@
#include <stc/cstack.h>
int main() {
- cstack_i stack = cstack_i_init();
- cstack_c chars = cstack_c_init();
- c_autodefer (cstack_i_del(&stack), cstack_c_del(&chars))
+ c_auto (cstack_i, stack)
+ c_auto (cstack_c, chars)
{
c_forrange (i, int, 101)
cstack_i_push(&stack, i*i);