aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt11
-rw-r--r--examples/hash.c23
2 files changed, 30 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4097a78..3dd2f15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,9 +15,12 @@ target_include_directories(bowl PUBLIC ".")
################### EXAMPLES ###################
if(BUILD_EXAMPLES)
- add_executable(ex_tree examples/tree.c)
- target_link_libraries(ex_tree bowl)
+ add_executable(example_tree examples/tree.c)
+ target_link_libraries(example_tree bowl)
- add_executable(ex_list examples/list.c)
- target_link_libraries(ex_list bowl)
+ add_executable(example_list examples/list.c)
+ target_link_libraries(example_list bowl)
+
+ add_executable(example_hash examples/hash.c)
+ target_link_libraries(example_hash bowl)
endif()
diff --git a/examples/hash.c b/examples/hash.c
new file mode 100644
index 0000000..7a06bbe
--- /dev/null
+++ b/examples/hash.c
@@ -0,0 +1,23 @@
+#include <bowl.h>
+
+int main()
+{
+
+ // Root node which contains a list
+ struct bowl *root;
+ bowl_malloc(&root, HASH);
+
+ struct bowl *a;
+ data_malloc(&a, LITERAL, "Destroy capitalism");
+ bowl_insert_key(root, "a", a);
+
+ struct bowl *b;
+ data_malloc(&b, INTEGER, 1312);
+ bowl_insert_key(root, "b", b);
+
+ struct bowl *c;
+ data_malloc(&c, LITERAL, "Alerta, Antifascista!");
+ bowl_insert_key(root, "c", c);
+
+ return bowl_free(root);
+}