Commit 4b9c6310 authored by osku's avatar osku

Add ib_list_create_heap().

parent 448636a7
......@@ -29,13 +29,25 @@ typedef struct ib_list_node_struct ib_list_node_t;
typedef struct ib_list_helper_struct ib_list_helper_t;
/********************************************************************
Create a new list. */
Create a new list using mem_alloc. Lists created with this function must be
freed with ib_list_free. */
ib_list_t*
ib_list_create(void);
/*=================*/
/* out: list */
/********************************************************************
Create a new list using the given heap. ib_list_free MUST NOT BE CALLED for
lists created with this function. */
ib_list_t*
ib_list_create_heap(
/*================*/
/* out: list */
mem_heap_t* heap); /* in: memory heap to use */
/********************************************************************
Free a list. */
......@@ -110,6 +122,8 @@ ib_list_get_last(
struct ib_list_struct {
ib_list_node_t* first; /* first node */
ib_list_node_t* last; /* last node */
ibool is_heap_list; /* TRUE if this list was
allocated through a heap */
};
/* A list node. */
......
......@@ -15,6 +15,26 @@ ib_list_create(void)
list->first = NULL;
list->last = NULL;
list->is_heap_list = FALSE;
return(list);
}
/********************************************************************
Create a new list using the given heap. ib_list_free MUST NOT BE CALLED for
lists created with this function. */
ib_list_t*
ib_list_create_heap(
/*================*/
/* out: list */
mem_heap_t* heap) /* in: memory heap to use */
{
ib_list_t* list = mem_heap_alloc(heap, sizeof(ib_list_t));
list->first = NULL;
list->last = NULL;
list->is_heap_list = TRUE;
return(list);
}
......@@ -27,6 +47,8 @@ ib_list_free(
/*=========*/
ib_list_t* list) /* in: list */
{
ut_a(!list->is_heap_list);
/* We don't check that the list is empty because it's entirely valid
to e.g. have all the nodes allocated from a single heap that is then
freed after the list itself is freed. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment