changeset 24:8ca38f736745

Fill allocated memory spaces by zero
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Wed, 13 Apr 2016 16:19:05 +0900
parents dcfd4b848886
children 38ba1606e62d
files src/insert_verification/akashaLLRBContext.c src/insert_verification/allocate.c
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/insert_verification/akashaLLRBContext.c	Tue Apr 12 14:07:58 2016 +0900
+++ b/src/insert_verification/akashaLLRBContext.c	Wed Apr 13 16:19:05 2016 +0900
@@ -1,4 +1,5 @@
 #include <stdlib.h>
+#include <string.h>
 
 #include "akashaLLRBContext.h"
 
@@ -62,6 +63,7 @@
     context->code      = malloc(sizeof(__code*)*context->codeNum);
     context->data      = malloc(sizeof(union Data*)*ALLOCATE_SIZE);
     context->heapStart = malloc(context->heapLimit);
+    memset(context->heapStart, context->heapLimit, 0);
 
 
     context->code[ShowTree]              = showTree_stub;
--- a/src/insert_verification/allocate.c	Tue Apr 12 14:07:58 2016 +0900
+++ b/src/insert_verification/allocate.c	Wed Apr 13 16:19:05 2016 +0900
@@ -1,5 +1,7 @@
+#include <stdio.h>
+#include <string.h>
+
 #include "llrbContext.h"
-#include <stdio.h>
 
 void* akashaMalloc(struct Context* context, size_t size) {
     context->data[++context->dataNum] = context->heap;
@@ -88,8 +90,9 @@
     newContext->heapStart = malloc(newContext->heapLimit);
     newContext->codeNum   = Exit;
     newContext->heap      = newContext->heapStart;
+    memset(newContext->heapStart, newContext->heapLimit, 0);
 
-    printf("reallocation! : %u\n", newContext->heapLimit);
+    printf("reallocation! : %lu\n", newContext->heapLimit);
 
     newContext->data[Allocate] = newContext->heap;
     newContext->heap += sizeof(struct Allocate);