diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -0,0 +1,31 @@ +#include "noleak.h" +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +void *alloc(size_t size) +{ + return noleak_alloc(size); +} + +int main(void) +{ + /* initialize noleak */ + if (noleak_init(1024 * 1024)) { + perror("noleak_init"); + return 1; + } + if (atexit(noleak_deinit)) { + perror("noleak_deinit"); + noleak_deinit(); + return 1; + } + + /* yolo */ + for (int i = 0; i < 512; i++) { + const size_t size = rand() % 1024; + char *const allocated = noleak_alloc(size); + memset(allocated, 'A', size); + } + return 0; +} |