aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..34d3348
--- /dev/null
+++ b/main.c
@@ -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;
+}