summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-06-30 12:54:40 -0400
committerJakob Kaivo <jkk@ung.org>2020-06-30 12:54:40 -0400
commit49ad475df150584a9e59649b48dec1f3bed2bffb (patch)
tree8e31c79b00356460335de9bb6652f2918a138b98 /test
parent3462b7ff75ce899b8761cd77b8b049658657593c (diff)
add simple realloc() test
Diffstat (limited to 'test')
-rw-r--r--test/realloc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/realloc.c b/test/realloc.c
new file mode 100644
index 0000000..c54f270
--- /dev/null
+++ b/test/realloc.c
@@ -0,0 +1,18 @@
+#define _POSIX_C_SOURCE 200809L
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include "mapalloc.h"
+
+int main(void)
+{
+ const char buf[] = "THIS IS A CONSTANT STRING";
+
+ char *ptr = map_realloc(NULL, sizeof(buf));
+ memcpy(ptr, buf, sizeof(buf));
+ printf("%p: %s\n", ptr, ptr);
+
+ ptr = map_realloc(ptr, sizeof(buf) * 2);
+ memcpy(ptr + sizeof(buf), buf, sizeof(buf));
+ printf("%p: %s\n", ptr, ptr);
+}