我正在尝试构建一个内存子分配器。我对下面的代码有一些错误,它告诉我:
free_list_ptr->next = &firstByte;
free_list_ptr->prev = &firstByte;
我收到 gcc 错误警告warning: assignment from incompatible pointer type
//primitive variable of byte as char, always positive.
typedef unsigned char byte;
static byte *memory = NULL;
struct header;
typedef struct _header {
int signiture;
int size;
struct header* next;
struct header* prev;
} header;
static header *free_list_ptr;
void allocator_init(u_int32_t size){
memory = (byte*) malloc(size);
//initialize free_list_ptr;
free_list_ptr = (header*) memory;
header* firstByte = (header*) memory;
free_list_ptr->size = size;
//error here: warning: assignment from incompatible pointer type
free_list_ptr->prev = &firstByte;
free_list_ptr->next = &firstByte;
}