#include "dstm.h"
+extern objstr_t *prefetchcache;
-objstr_t *objstrCreate(unsigned int size)
-{
- objstr_t *tmp = malloc(sizeof(objstr_t) + size);
- tmp->size = size;
- tmp->top = tmp + 1; //points to end of objstr_t structure!
- return tmp;
+objstr_t *objstrCreate(unsigned int 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!
+ return tmp;
}
//free entire list, starting at store
{ //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;
store->size = 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;
+ store->next = NULL;
store->size = DEFAULT_OBJ_STORE_SIZE;
}
store->top = (void *)((unsigned int)store + sizeof(objstr_t) + size);
}
}
+void clearObjStore() {
+ objstr_t *tmp = prefetchcache;
+ while(tmp != NULL) {
+ bzero(tmp+1, tmp->size);
+ tmp = tmp->next;
+ }
+}