In an implementation of a basic pool i have something like this(i'll simplify the code to be clearer)
struct unit_header{
struct unit_header* next, prev;
};
int number_of_units = 10
int unit_size = 5;
int full_block = number_of_units*(unit_size+sizeof(struct unit_header));
void* p_mem_full_block = malloc(full_block);
//iterate all units of mem_full_block
for (int i = 0; i< number_of_units; i++){
//pointer to each unit
struct unit_header* p_units = (struct unit_header*)((char*)p_mem_full_block + i*(unit_size+sizeof(struct unit_header)));
//.... some pointers stuff....
}
I do know that this part(below) is used to go through all units of mem_block...
i * (unit_size+sizeof(struct unit_header))
I did not get what this part:
(char*)p_mem_full_block
means. Why do I have to make this char* conversion?