rem: if (lastBuffer) {
add: if (headBuffer) { headBuffer->flags |= CBUF_FLAG_CHAIN_HEAD; lastBuffer->flags |= CBUF_FLAG_CHAIN_TAIL;
context: allocate_cbuf_mem(size_t size){	void *_buffer;	cbuf *buffer = NULL;	cbuf *lastBuffer = NULL;	cbuf *headBuffer = NULL;	int i;	int count;	size_t foundSize;	size = PAGE_ALIGN(size);	while (size > 0) {		foundSize = size;		_buffer = allocate_cbuf(&foundSize);		if (!_buffer) {			// couldn't allocate, lets bail with what we have			break;		}		size -= foundSize;		count = foundSize / CBUF_LENGTH;//		dprintf("allocate_cbuf_mem: returned %d of memory, %d left\n", found_size, size);		buffer = (cbuf *)_buffer;		if (headBuffer == NULL) {			headBuffer = buffer;			headBuffer->flags |= CBUF_FLAG_CHAIN_HEAD;		}		for (i = 0; i < count; i++) {			initialize_cbuf(buffer);			if (lastBuffer)				lastBuffer->next = buffer;			if (headBuffer)				buffer->total_length += buffer->length;			lastBuffer = buffer;			buffer++;		}	}	if (lastBuffer) {		lastBuffer->next = NULL;		lastBuffer->flags |= CBUF_FLAG_CHAIN_TAIL;	}	return headBuffer;}