fix memory corruption errors and replace mallocs with calloc.
[IRC.git] / Robust / src / Runtime / DSTM / interface / objstr.c
index 906573385c6cd78ff0062e47211f8c8ed30d81fd..20004396c34c7814cb04e835fce9e5b9d5e469e7 100644 (file)
@@ -2,7 +2,7 @@
 
 objstr_t *objstrCreate(unsigned int size)
 {
-       objstr_t *tmp = malloc(sizeof(objstr_t) + size);
+       objstr_t *tmp = calloc(1, (sizeof(objstr_t) + size));
        tmp->size = size;
        tmp->next = NULL;
        tmp->top = tmp + 1; //points to end of objstr_t structure!
@@ -38,7 +38,7 @@ void *objstrAlloc(objstr_t *store, unsigned int size)
                {  //end of list, all full
                        if (size > DEFAULT_OBJ_STORE_SIZE) //in case of large objects
                        {
-                               store->next = (objstr_t *)malloc(sizeof(objstr_t) + size);
+                               store->next = (objstr_t *)calloc(1,(sizeof(objstr_t) + size));
                                if (store->next == NULL)
                                        return NULL;
                                store = store->next;
@@ -46,7 +46,7 @@ void *objstrAlloc(objstr_t *store, unsigned int size)
                        }
                        else
                        {
-                               store->next = malloc(sizeof(objstr_t) + DEFAULT_OBJ_STORE_SIZE);
+                               store->next = calloc(1,(sizeof(objstr_t) + DEFAULT_OBJ_STORE_SIZE));
                                if (store->next == NULL)
                                        return NULL;
                                store = store->next;