Drizzled Public API Documentation

ut0list.h File Reference
#include "mem0mem.h"

Go to the source code of this file.

Classes

struct  ib_list_struct
 
struct  ib_list_node_struct
 
struct  ib_list_helper_struct
 

Macros

#define IB_LIST_H
 

Typedefs

typedef struct ib_list_struct ib_list_t
 
typedef struct ib_list_node_struct ib_list_node_t
 
typedef struct
ib_list_helper_struct 
ib_list_helper_t
 

Functions

UNIV_INTERN ib_list_tib_list_create (void)
 
UNIV_INTERN ib_list_tib_list_create_heap (mem_heap_t *heap)
 
UNIV_INTERN void ib_list_free (ib_list_t *list)
 
UNIV_INTERN ib_list_node_tib_list_add_first (ib_list_t *list, void *data, mem_heap_t *heap)
 
UNIV_INTERN ib_list_node_tib_list_add_last (ib_list_t *list, void *data, mem_heap_t *heap)
 
UNIV_INTERN ib_list_node_tib_list_add_after (ib_list_t *list, ib_list_node_t *prev_node, void *data, mem_heap_t *heap)
 
UNIV_INTERN void ib_list_remove (ib_list_t *list, ib_list_node_t *node)
 
UNIV_INLINE ib_list_node_tib_list_get_first (ib_list_t *list)
 
UNIV_INLINE ib_list_node_tib_list_get_last (ib_list_t *list)
 

Detailed Description

A double-linked list

Created 4/26/2006 Osku Salerma

Definition in file ut0list.h.

Macro Definition Documentation

#define IB_LIST_H

A double-linked list. This differs from the one in ut0lst.h in that in this one, each list node contains a pointer to the data, whereas the one in ut0lst.h uses a strategy where the list pointers are embedded in the data items themselves.

Use this one when you need to store arbitrary data in the list where you can't embed the list pointers in the data, if a data item needs to be stored in multiple lists, etc.

Note about the memory management: ib_list_t is a fixed-size struct whose allocation/deallocation is done through ib_list_create/ib_list_free, but the memory for the list nodes is allocated through a user-given memory heap, which can either be the same for all nodes or vary per node. Most users will probably want to create a memory heap to store the item-specific data, and pass in this same heap to the list node creation functions, thus automatically freeing the list node when the item's heap is freed.

Definition at line 48 of file ut0list.h.

Function Documentation

UNIV_INTERN ib_list_node_t* ib_list_add_after ( ib_list_t list,
ib_list_node_t prev_node,
void *  data,
mem_heap_t heap 
)

Add the data after the indicated node.

Returns
new list node in: memory heap to use

Add the data after the indicated node.

Returns
new list node
Parameters
listin: list
prev_nodein: node preceding new node (can be NULL)
datain: data
heapin: memory heap to use

Definition at line 117 of file ut0list.cc.

References ib_list_node_struct::data, ib_list_struct::first, ib_list_add_after(), ib_list_struct::last, mem_heap_alloc(), ib_list_node_struct::next, ib_list_node_struct::prev, and ut_a.

Referenced by ib_list_add_after(), ib_list_add_first(), and ib_list_add_last().

UNIV_INTERN ib_list_node_t* ib_list_add_first ( ib_list_t list,
void *  data,
mem_heap_t heap 
)

Add the data to the start of the list.

Returns
new list node in: memory heap to use

Add the data to the start of the list.

Returns
new list node
Parameters
listin: list
datain: data
heapin: memory heap to use

Definition at line 89 of file ut0list.cc.

References ib_list_add_after(), ib_list_add_first(), and ib_list_get_first().

Referenced by ib_list_add_first().

UNIV_INTERN ib_list_node_t* ib_list_add_last ( ib_list_t list,
void *  data,
mem_heap_t heap 
)

Add the data to the end of the list.

Returns
new list node in: memory heap to use

Add the data to the end of the list.

Returns
new list node
Parameters
listin: list
datain: data
heapin: memory heap to use

Definition at line 103 of file ut0list.cc.

References ib_list_add_after(), ib_list_add_last(), and ib_list_get_last().

Referenced by ib_list_add_last(), and ib_wqueue_add().

UNIV_INTERN ib_list_t* ib_list_create ( void  )

Create a new list using mem_alloc. Lists created with this function must be freed with ib_list_free.

Returns
list

Create a new list.

Returns
list

Definition at line 36 of file ut0list.cc.

References ib_list_struct::first, ib_list_create(), ib_list_struct::is_heap_list, and ib_list_struct::last.

Referenced by ib_list_create(), and ib_wqueue_create().

UNIV_INTERN ib_list_t* ib_list_create_heap ( mem_heap_t heap)

Create a new list using the given heap. ib_list_free MUST NOT BE CALLED for lists created with this function.

Returns
list in: memory heap to use

Create a new list using the given heap. ib_list_free MUST NOT BE CALLED for lists created with this function.

Returns
list
Parameters
heapin: memory heap to use

Definition at line 54 of file ut0list.cc.

References ib_list_struct::first, ib_list_create_heap(), ib_list_struct::is_heap_list, ib_list_struct::last, and mem_heap_alloc().

Referenced by ib_list_create_heap().

UNIV_INTERN void ib_list_free ( ib_list_t list)

Free a list. in: list

Free a list.

Parameters
listin: list

Definition at line 71 of file ut0list.cc.

References ib_list_free(), ib_list_struct::is_heap_list, mem_free, and ut_a.

Referenced by ib_list_free(), and ib_wqueue_free().

UNIV_INLINE ib_list_node_t* ib_list_get_first ( ib_list_t list)

Get the first node in the list.

Returns
first node, or NULL in: list

Referenced by ib_list_add_first(), ib_wqueue_free(), and ib_wqueue_wait().

UNIV_INLINE ib_list_node_t* ib_list_get_last ( ib_list_t list)

Get the last node in the list.

Returns
last node, or NULL in: list

Referenced by ib_list_add_last().

UNIV_INTERN void ib_list_remove ( ib_list_t list,
ib_list_node_t node 
)

Remove the node from the list. in: node to remove

Remove the node from the list.

Parameters
listin: list
nodein: node to remove

Definition at line 170 of file ut0list.cc.

References ib_list_struct::first, ib_list_remove(), ib_list_struct::last, ib_list_node_struct::next, ib_list_node_struct::prev, and ut_ad.

Referenced by ib_list_remove(), and ib_wqueue_wait().