summaryrefslogtreecommitdiff
path: root/test/malloc/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/malloc/malloc.c')
-rw-r--r--test/malloc/malloc.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/malloc/malloc.c b/test/malloc/malloc.c
index 698ab5e70..ac40ec6a2 100644
--- a/test/malloc/malloc.c
+++ b/test/malloc/malloc.c
@@ -10,8 +10,17 @@
#define random_size() (random()%MAX_SIZE)
#define random_ptr() (random()%N_PTRS)
+void test1(void);
+void test2(void);
+
int main(int argc,char *argv[])
{
+ test1();
+ test2();
+}
+
+void test1(void)
+{
void **ptrs;
int i,j;
int size;
@@ -37,7 +46,24 @@ int main(int argc,char *argv[])
for(i=0;i<N_PTRS;i++){
free(ptrs[i]);
}
+}
- return 0;
+void test2(void)
+{
+ void *ptr = NULL;
+
+ ptr = realloc(ptr,100);
+ if(!ptr){
+ printf("couldn't realloc() a NULL pointer\n");
+ }else{
+ free(ptr);
+ }
+
+ ptr = malloc(100);
+ ptr = realloc(ptr, 0);
+ if(ptr){
+ printf("realloc(,0) failed\n");
+ free(ptr);
+ }
}