3 objstr_t *objstrCreate(unsigned int size) {
5 if((tmp = calloc(1, (sizeof(objstr_t) + size))) == NULL) {
6 printf("%s() Calloc error at line %d, %s\n", __func__, __LINE__, __FILE__);
11 tmp->top = tmp + 1; //points to end of objstr_t structure!
15 //free entire list, starting at store
16 void objstrDelete(objstr_t *store) {
18 while (store != NULL) {
26 void *objstrAlloc(objstr_t *store, unsigned int size) {
29 if (((unsigned int)store->top - (((unsigned int)store) + sizeof(objstr_t)) + size) <= store->size) { //store not full
35 if (store->next == NULL) {
36 //end of list, all full
37 if (size > DEFAULT_OBJ_STORE_SIZE) {
38 //in case of large objects
39 if((store->next = (objstr_t *)calloc(1,(sizeof(objstr_t) + size))) == NULL) {
40 printf("%s() Calloc error at line %d, %s\n", __func__, __LINE__, __FILE__);
46 if((store->next = calloc(1,(sizeof(objstr_t) + DEFAULT_OBJ_STORE_SIZE))) == NULL) {
47 printf("%s() Calloc error at line %d, %s\n", __func__, __LINE__, __FILE__);
51 store->size = DEFAULT_OBJ_STORE_SIZE;
53 store->top = (void *)(((unsigned int)store) + sizeof(objstr_t) + size);
54 return (void *)(((unsigned int)store) + sizeof(objstr_t));