summaryrefslogtreecommitdiff
path: root/test/malloc
diff options
context:
space:
mode:
Diffstat (limited to 'test/malloc')
-rw-r--r--test/malloc/Makefile27
-rw-r--r--test/malloc/realloc0.c13
2 files changed, 40 insertions, 0 deletions
diff --git a/test/malloc/Makefile b/test/malloc/Makefile
index aaa2976d6..ba0c86e50 100644
--- a/test/malloc/Makefile
+++ b/test/malloc/Makefile
@@ -23,6 +23,7 @@ include $(TESTDIR)/Rules.mak
TARGETS=malloc
TARGETS+=testmalloc testmalloc_glibc
TARGETS+=mallocbug mallocbug_glibc
+TARGETS+=realloc0 realloc0_glibc
all: $(TARGETS)
malloc: malloc.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(CC)
@@ -95,6 +96,32 @@ mallocbug_glibc: mallocbug.c Makefile
-./$@
-@ echo " "
+realloc0: realloc0.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(CC)
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs uClibc: "
+ -@ echo " "
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
+realloc0_glibc: realloc0.c Makefile
+ -@ echo "-------"
+ -@ echo " "
+ -@ echo "Compiling vs GNU libc: "
+ -@ echo " "
+ $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o
+ $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@
+ $(STRIPTOOL) -x -R .note -R .comment $@
+ -$(LDD) $@
+ ls -l $@
+ -./$@
+ -@ echo " "
+
clean:
rm -f *.[oa] *~ core $(TARGETS)
diff --git a/test/malloc/realloc0.c b/test/malloc/realloc0.c
new file mode 100644
index 000000000..afe9bb9bd
--- /dev/null
+++ b/test/malloc/realloc0.c
@@ -0,0 +1,13 @@
+#include <stdlib.h>
+
+int main(int argc, char **argv)
+{
+ void *ptr = NULL;
+ ptr = realloc(ptr, 0);
+ printf("realloc(NULL, 0) -- pointer = %p\n", ptr);
+
+ ptr = malloc(0);
+ printf("malloc(0) -- pointer = %p\n", ptr);
+ return 0;
+}
+