]> git.ozlabs.org Git - ccan/blobdiff - ccan/idtree/idtree.c
idtree: use ccan/tal instead of talloc
[ccan] / ccan / idtree / idtree.c
index 5a26234e63318e92c06193d7e994c2a99d10e5f9..e8873926a79c07a21b7b843f06b3b4cfaa7078c9 100644 (file)
@@ -25,7 +25,7 @@
 */
 
 #include <ccan/idtree/idtree.h>
-#include <ccan/talloc/talloc.h>
+#include <ccan/tal/tal.h>
 #include <stdint.h>
 #include <string.h>
 
@@ -87,7 +87,7 @@ static void free_layer(struct idtree *idp, struct idtree_layer *p)
 static int idtree_pre_get(struct idtree *idp)
 {
        while (idp->id_free_cnt < IDTREE_FREE_MAX) {
-               struct idtree_layer *pn = talloc_zero(idp, struct idtree_layer);
+               struct idtree_layer *pn = talz(idp, struct idtree_layer);
                if(pn == NULL)
                        return (0);
                free_layer(idp, pn);
@@ -99,7 +99,7 @@ static int sub_alloc(struct idtree *idp, const void *ptr, int *starting_id)
 {
        int n, m, sh;
        struct idtree_layer *p, *pn;
-       struct idtree_layer *pa[MAX_LEVEL];
+       struct idtree_layer *pa[MAX_LEVEL+1];
        unsigned int l, id, oid;
        uint32_t bm;
 
@@ -313,14 +313,14 @@ bool idtree_remove(struct idtree *idp, int id)
        }
        while (idp->id_free_cnt >= IDTREE_FREE_MAX) {
                p = alloc_layer(idp);
-               talloc_free(p);
+               tal_free(p);
        }
        return true;
 }
 
 struct idtree *idtree_new(void *mem_ctx)
 {
-       return talloc_zero(mem_ctx, struct idtree);
+       return talz(mem_ctx, struct idtree);
 }
 
 int idtree_add(struct idtree *idp, const void *ptr, int limit)