mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 19:11:46 +01:00
Add ib_list_create_heap().
This commit is contained in:
parent
448636a7cb
commit
4b9c631072
2 changed files with 37 additions and 1 deletions
|
@ -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. */
|
||||
|
|
22
ut/ut0list.c
22
ut/ut0list.c
|
@ -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. */
|
||||
|
|
Loading…
Add table
Reference in a new issue