]> git.ozlabs.org Git - ccan/blobdiff - ccan/talloc/test/run-external-alloc.c
talloc: spelling fix.
[ccan] / ccan / talloc / test / run-external-alloc.c
index fb1e17e95f1e14301b2d132b34dd0f0672fff67d..0dc9346075a84a49a53a39ca47d76de6873e7a73 100644 (file)
@@ -1,8 +1,10 @@
-#include "talloc/talloc.c"
-#include "tap/tap.h"
+#include <ccan/talloc/talloc.c>
+#include <ccan/tap/tap.h>
 #include <assert.h>
 
-static int ext_alloc_count, ext_free_count, ext_realloc_count;
+/* Much testing already done in run.c */
+
+static int ext_alloc_count, ext_free_count, ext_realloc_count, lock_count, unlock_count;
 static void *expected_parent;
 
 static void *ext_realloc(const void *parent, void *ptr, size_t size)
@@ -17,13 +19,23 @@ static void *ext_realloc(const void *parent, void *ptr, size_t size)
        return realloc(ptr, size);
 }
 
+static void ext_lock(const void *ctx)
+{
+       lock_count++;
+}
+
+static void ext_unlock(void)
+{
+       unlock_count++;
+}
+
 int main(void)
 {
        char *p, *p2, *head;
-       plan_tests(12);
+       plan_tests(15);
 
        expected_parent = NULL;
-       head = talloc_add_external(NULL, ext_realloc);
+       head = talloc_add_external(NULL, ext_realloc, ext_lock, ext_unlock);
        assert(head);
        ok1(ext_alloc_count == 1);
 
@@ -50,5 +62,11 @@ int main(void)
        talloc_free(p);
        ok1(ext_free_count == 2);
 
+       expected_parent = NULL;
+       talloc_free(head);
+       ok1(ext_free_count == 3);
+
+       ok1(lock_count == unlock_count);
+
        return exit_status();
 }