diff options
| author | William Casarin <jb55@jb55.com> | 2018-07-09 22:28:25 -0700 |
|---|---|---|
| committer | William Casarin <jb55@jb55.com> | 2018-07-09 22:31:48 -0700 |
| commit | 9593fc545950782ed75f12f53238b07885559b2b (patch) | |
| tree | 9c7c2f7cbb427c54e9184cb61eedce737a6cbc6f /ccan/tal/test/run-test-backend.c | |
| parent | bd8c223756d2f912526ecef53bae0cc8e0c63442 (diff) | |
remove ccan for now
Diffstat (limited to 'ccan/tal/test/run-test-backend.c')
| -rw-r--r-- | ccan/tal/test/run-test-backend.c | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/ccan/tal/test/run-test-backend.c b/ccan/tal/test/run-test-backend.c deleted file mode 100644 index ebcd811..0000000 --- a/ccan/tal/test/run-test-backend.c +++ /dev/null @@ -1,80 +0,0 @@ -#include <stdlib.h> -#include <stdbool.h> - -/* Make sure it always uses our allocation/resize/free fns! */ -static bool my_alloc_called; - -static void *my_alloc(size_t len) -{ - my_alloc_called = true; - return (char *)malloc(len + 16) + 16; -} - -static void my_free(void *p) -{ - if (p) - free((char *)p - 16); -} - -static void *my_realloc(void *old, size_t new_size) -{ - return (char *)realloc((char *)old - 16, new_size + 16) + 16; -} - -#define free ((void (*)(void *))abort) -#define malloc ((void *(*)(size_t))abort) -#define realloc ((void *(*)(void *, size_t))abort) - -#include <ccan/tal/tal.h> -#include <ccan/tal/tal.c> -#include <ccan/tap/tap.h> - -#define NUM_ALLOCS 1000 - -static void destroy_p(void *p UNNEEDED) -{ -} - -int main(void) -{ - void *p, *c[NUM_ALLOCS]; - int i; - char *name; - - /* Mostly we rely on the allocator (or valgrind) crashing. */ - plan_tests(1); - - tal_set_backend(my_alloc, my_realloc, my_free, NULL); - - p = tal(NULL, char); - ok1(my_alloc_called); - - /* Adding properties makes us allocated. */ - tal_add_destructor(p, destroy_p); - - tal_set_name(p, "test"); - name = tal_arr(NULL, char, 6); - strcpy(name, "test2"); - tal_set_name(p, name); - /* makes us free old name */ - tal_set_name(p, name); - tal_free(name); - - /* Add lots of children. */ - for (i = 0; i < NUM_ALLOCS; i++) - c[i] = tal(p, char); - - /* Now steal a few. */ - for (i = 1; i < NUM_ALLOCS / 2; i++) - tal_steal(c[0], c[i]); - - /* Now free individual ones.. */ - for (i = NUM_ALLOCS / 2; i < NUM_ALLOCS; i++) - tal_free(c[i]); - - /* Finally, free the parent. */ - tal_free(p); - - tal_cleanup(); - return exit_status(); -} |
