diff options
Diffstat (limited to 'development/libs/libbowl/examples/tree.c')
-rw-r--r-- | development/libs/libbowl/examples/tree.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/development/libs/libbowl/examples/tree.c b/development/libs/libbowl/examples/tree.c new file mode 100644 index 000000000000..eb1b33a8d42f --- /dev/null +++ b/development/libs/libbowl/examples/tree.c @@ -0,0 +1,46 @@ +#include <bowl.h> + +int main() +{ + err_t e; + + // Initialise a root node + struct bowl *root; + e = bowl_malloc(&root, ARRAY); + if(e) return e; + + // First Node + struct bowl *a; + e = data_malloc(&a, LITERAL, "Destroy capitalism"); + if(e) return e; + + // Second Node + struct bowl *b; + e = data_malloc(&b, INTEGER, 1312); + if(e) return e; + + // Third node is another ARRAY + struct bowl *c; + e = bowl_malloc(&c, ARRAY); + if(e) return e; + + // Fourth node is another string + struct bowl *d; + e = data_malloc(&d, LITERAL, "Alerta, Antifascista!"); + if(e) return e; + + // Add the d node to c + e = bowl_append(c, d); + if(e) e; + + // Add other nodes to root + e = bowl_append(root, a); + if(e) return e; + e = bowl_append(root, b); + if(e) return e; + e = bowl_append(root, c); + if(e) return e; + + e = bowl_free(root); + return e; +} |