This is a good question. Accepting your structure at face value and assuming curr and next should be pointers to other occurrences of the same structure (will also require code modification per other answers), then init
should be coded as:
void init( buffer_t* b, int size ) {
b->size = (size_t) size;
b->buffer = (uint8_t*) malloc( sizeof(uint8_t) * b->size + 1 );
b->curr = b; // a self-pointer to this buffer_t
b->next = NULL; // pointer to next buffer_t structure
}
b->buffer
points to storage allocated on the heap, while the buffer_t
structure is part of a linked list used to manage many different buffers.