aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md33
1 files changed, 33 insertions, 0 deletions
diff --git a/README.md b/README.md
index 4644332..bd9ac7b 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,39 @@ I hope you enjoy ❤
[badge-link]: https://builds.sr.ht/~spacekookie/libbowl?
[issues]: https://todo.sr.ht/~spacekookie/libbowl
+Exampple
+--------
+
+The root structure in `libbowl` is a `bowl`. It can either be a leaf
+node, containing some data (`bowl_data`, which can be many types),
+or be a structure node, either in `ARRAY`, `LINK` or `HASH` mode.
+
+Each `libbowl` function returns a status code and uses reverse-input
+pointers to communicate results. A convenience `DEBUG` macro is included.
+
+```C
+bowl *list;
+int r = bowl_malloc(&list, ARRAY);
+if(r) { printf("Failed to malloc!\n"); exit(2); }
+
+// `DEBUG` does the same thing as the above `if`
+bowl *number;
+DEBUG (data_malloc(&number, INTEGER, 1312))
+
+// Finally append data into list
+DEBUG (bowl_append(list, number))
+```
+
+Generally, `data` prefixed functions are convenience wrappers around
+allocating a `bowl`, setting it's type to `LEAF`, and inserting some
+data into it (performing at least 2 allocation calls).
+
+Freeing a `bowl` structure is as easy as calling free on the top node.
+
+```C
+// ...
+DEBUG (bowl_free(list))
+```
How to build
------------