4 #define OSUSED(x) (((unsigned int)(x)->top)-((unsigned int) (x+1)))
5 #define OSFREE(x) ((x)->size-OSUSED(x))
7 objstr_t *objstrCreate(unsigned int size) {
9 if((tmp = calloc(1, (sizeof(objstr_t) + size))) == NULL) {
10 printf("%s() Calloc error at line %d, %s\n", __func__, __LINE__, __FILE__);
15 tmp->top = tmp + 1; //points to end of objstr_t structure!
19 //free entire list, starting at store
20 void objstrDelete(objstr_t *store) {
22 while (store != NULL) {
30 void *objstrAlloc(objstr_t **osptr, unsigned int size) {
33 objstr_t *store=*osptr;
39 if (OSFREE(store)>=size) {
44 if ((store=store->next)==NULL)
49 unsigned int newsize=size>DEFAULT_OBJ_STORE_SIZE ? size : DEFAULT_OBJ_STORE_SIZE;
50 objstr_t *os=(objstr_t *)calloc(1,(sizeof(objstr_t) + newsize));
55 os->top=((char *)ptr)+size;