#ifndef LINKED_LIST_H #define LINKED_LIST_H struct linked_list { struct list_chunk **chunks_array; /* array of pointers to list_chunk structures */ int chunks_array_size; /* size of the array */ int allocated_chunks; /* chunks_array[allocated_chunks-1] is the last allocated chunk */ int chunk_size; /* size of the next chunk to be allocated */ int unit_size; /* size of each user defined unit */ }; struct list_chunk { struct linked_list *owner; /* the list to which this chunks belongs */ int ca_index; /* index in the chunks_array */ char *mem; /* pointer to an allocated block of memory for the chunk */ int size; /* number of allocated units */ int available_unit; /* next available unit */ int freed; /* number of freed units */ }; /* Creates new linked_list structure */ struct linked_list *list_init(int unit_size); /* Frees all memory allocated for the list */ void list_destroy(struct linked_list *list); /* Returns pointer to an available unit_size bytes block of memory */ void *list_malloc(struct linked_list *list); /* Marks the memory block poined by ptr as free */ void list_free(struct linked_list *list, void *ptr); #endif