/* allocates a new chunk of X nodes, and links them all together as a list. Uses the cnode->next and cnode->prev pointers returns NULL on failure  */
static struct reiserfs_journal_cnode* allocate_cnodes(int num_cnodes)
/* allocates a new chunk of X nodes, and links them all together as a list. Uses the cnode->next and cnode->prev pointers returns NULL on failure  */
static struct reiserfs_journal_cnode* allocate_cnodes(int num_cnodes)
{
	struct reiserfs_journal_cnode *head;
	int i;
	if (num_cnodes <= 0) {
		return NULL;
	}
	head = vmalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode));
	if (!head) {
		return NULL;
	}
	memset(head, 0, num_cnodes * sizeof(struct reiserfs_journal_cnode));
	head[0].prev = NULL;
	head[0].next = head + 1;
	for (i = 1; i < num_cnodes; i++) {
		head[i].prev = head + (i - 1);
		head[i].next = head + (i + 1);
	}
	head[num_cnodes - 1].next = NULL;
	return head;
}