InnoDB Plugin  1.0
Macros | Functions | Variables
mem0mem.ic File Reference
#include "mem0dbg.ic"
#include "mem0pool.h"
Include dependency graph for mem0mem.ic:
This graph shows which files directly or indirectly include this file:

Macros

#define mem_heap_create_block(heap, n, type, file_name, line)   mem_heap_create_block_func(heap, n, file_name, line, type)
#define mem_heap_create_at(N, file_name, line)   mem_heap_create_func(N, file_name, line, MEM_HEAP_DYNAMIC)

Functions

UNIV_INTERN mem_block_tmem_heap_create_block_func (mem_heap_t *heap, ulint n, const char *file_name, ulint line, ulint type)
UNIV_INTERN void mem_heap_block_free (mem_heap_t *heap, mem_block_t *block)
UNIV_INTERN void mem_heap_free_block_free (mem_heap_t *heap)
UNIV_INTERN mem_block_tmem_heap_add_block (mem_heap_t *heap, ulint n)
UNIV_INLINE void mem_block_set_len (mem_block_t *block, ulint len)
UNIV_INLINE ulint mem_block_get_len (mem_block_t *block)
UNIV_INLINE void mem_block_set_type (mem_block_t *block, ulint type)
UNIV_INLINE ulint mem_block_get_type (mem_block_t *block)
UNIV_INLINE void mem_block_set_free (mem_block_t *block, ulint free)
UNIV_INLINE ulint mem_block_get_free (mem_block_t *block)
UNIV_INLINE void mem_block_set_start (mem_block_t *block, ulint start)
UNIV_INLINE ulint mem_block_get_start (mem_block_t *block)
UNIV_INLINE void * mem_heap_zalloc (mem_heap_t *heap, ulint n)
UNIV_INLINE void * mem_heap_alloc (mem_heap_t *heap, ulint n)
UNIV_INLINE byte * mem_heap_get_heap_top (mem_heap_t *heap)
UNIV_INLINE void mem_heap_free_heap_top (mem_heap_t *heap, byte *old_top)
UNIV_INLINE void mem_heap_empty (mem_heap_t *heap)
UNIV_INLINE void * mem_heap_get_top (mem_heap_t *heap, ulint n)
UNIV_INLINE void mem_heap_free_top (mem_heap_t *heap, ulint n)
UNIV_INLINE mem_heap_tmem_heap_create_func (ulint n, const char *file_name, ulint line, ulint type)
UNIV_INLINE void mem_heap_free_func (mem_heap_t *heap, const char *file_name)
 ut_ad (mem_heap_check(heap))
 if (heap->free_block)
 while (block!=NULL)
UNIV_INLINE void * mem_alloc_func (ulint n, const char *file_name, ulint line, ulint *size)
UNIV_INLINE void mem_free_func (void *ptr, const char *file_name, ulint line)
UNIV_INLINE ulint mem_heap_get_size (mem_heap_t *heap)
UNIV_INLINE char * mem_strdup (const char *str)
UNIV_INLINE char * mem_strdupl (const char *str, ulint len)
UNIV_INLINE char * mem_heap_strdupl (mem_heap_t *heap, const char *str, ulint len)

Variables

UNIV_INLINE void ulint line
mem_block_t
block = UT_LIST_GET_LAST(heap->base)
mem_block_tprev_block

Detailed Description

The memory management

Created 6/8/1994 Heikki Tuuri

Function Documentation

UNIV_INLINE void* mem_alloc_func ( ulint  n,
const char *  file_name,
ulint  line,
ulint *  size 
)

NOTE: Use the corresponding macro instead of this function. Allocates a single buffer of memory from the dynamic memory of the C compiler. Is like malloc of C. The buffer must be freed with mem_free.

Returns
own: free storage
Parameters
nin: desired number of bytes
file_namein: file name where created
linein: line where created
sizeout: allocated size in bytes, or NULL
UNIV_INLINE void mem_free_func ( void *  ptr,
const char *  file_name,
ulint  line 
)

NOTE: Use the corresponding macro instead of this function. Frees a single buffer of storage from the dynamic memory of the C compiler. Similar to the free of C.

Parameters
ptrin, own: buffer to be freed
file_namein: file name where created
linein: line where created
UNIV_INTERN mem_block_t* mem_heap_add_block ( mem_heap_t heap,
ulint  n 
)

Adds a new block to a memory heap.

Returns
created block, NULL if did not succeed (only possible for MEM_HEAP_BTR_SEARCH type heaps) in: number of bytes user needs
Parameters
heapin: memory heap
UNIV_INLINE void* mem_heap_alloc ( mem_heap_t heap,
ulint  n 
)

Allocates n bytes of memory from a memory heap.

Returns
allocated storage, NULL if did not succeed (only possible for MEM_HEAP_BTR_SEARCH type heaps)
Parameters
heapin: memory heap
nin: number of bytes; if the heap is allowed to grow into the buffer pool, this must be <= MEM_MAX_ALLOC_IN_BUF
UNIV_INTERN void mem_heap_block_free ( mem_heap_t heap,
mem_block_t block 
)

Frees a block from a memory heap. in: block to free

Parameters
heapin: heap
UNIV_INTERN mem_block_t* mem_heap_create_block_func ( mem_heap_t heap,
ulint  n,
const char *  file_name,
ulint  line,
ulint  type 
)

Creates a memory heap block where data can be allocated.

Returns
own: memory heap block, NULL if did not succeed (only possible for MEM_HEAP_BTR_SEARCH type heaps) in: type of heap: MEM_HEAP_DYNAMIC or MEM_HEAP_BUFFER
Parameters
heapin: memory heap or NULL if first block should be created
nin: number of bytes needed for user data
file_namein: file name where created
linein: line where created
UNIV_INLINE mem_heap_t* mem_heap_create_func ( ulint  n,
const char *  file_name,
ulint  line,
ulint  type 
)

NOTE: Use the corresponding macros instead of this function. Creates a memory heap. For debugging purposes, takes also the file name and line as argument.

Returns
own: memory heap, NULL if did not succeed (only possible for MEM_HEAP_BTR_SEARCH type heaps)
Parameters
nin: desired start block size, this means that a single user buffer of size n will fit in the block, 0 creates a default size block
file_namein: file name where created
linein: line where created
typein: heap type
UNIV_INLINE void mem_heap_empty ( mem_heap_t heap)

Empties a memory heap. The first memory block of the heap is not freed.

Parameters
heapin: heap to empty
UNIV_INTERN void mem_heap_free_block_free ( mem_heap_t heap)

Frees the free_block field from a memory heap. in: heap

UNIV_INLINE void mem_heap_free_func ( mem_heap_t heap,
const char *  file_name 
)

NOTE: Use the corresponding macro instead of this function. Frees the space occupied by a memory heap. In the debug version erases the heap memory blocks.

Parameters
heapin, own: heap to be freed
UNIV_INLINE void mem_heap_free_heap_top ( mem_heap_t heap,
byte *  old_top 
)

Frees the space in a memory heap exceeding the pointer given. The pointer must have been acquired from mem_heap_get_heap_top. The first memory block of the heap is not freed.

Parameters
heapin: heap from which to free
old_topin: pointer to old top of heap
UNIV_INLINE void mem_heap_free_top ( mem_heap_t heap,
ulint  n 
)

Frees the topmost element in a memory heap. The size of the element must be given.

Parameters
heapin: memory heap
nin: size of the topmost element
UNIV_INLINE byte* mem_heap_get_heap_top ( mem_heap_t heap)

Returns a pointer to the heap top.

Returns
pointer to the heap top
Parameters
heapin: memory heap
UNIV_INLINE ulint mem_heap_get_size ( mem_heap_t heap)

Returns the space in bytes occupied by a memory heap.

Parameters
heapin: heap
UNIV_INLINE void* mem_heap_get_top ( mem_heap_t heap,
ulint  n 
)

Returns a pointer to the topmost element in a memory heap. The size of the element must be given.

Returns
pointer to the topmost element
Parameters
heapin: memory heap
nin: size of the topmost element
UNIV_INLINE char* mem_heap_strdupl ( mem_heap_t heap,
const char *  str,
ulint  len 
)

Makes a NUL-terminated copy of a nonterminated string, allocated from a memory heap.

Returns
own: a copy of the string
Parameters
heapin: memory heap where string is allocated
strin: string to be copied
lenin: length of str, in bytes
UNIV_INLINE void* mem_heap_zalloc ( mem_heap_t heap,
ulint  n 
)

Allocates and zero-fills n bytes of memory from a memory heap.

Returns
allocated, zero-filled storage
Parameters
heapin: memory heap
nin: number of bytes; if the heap is allowed to grow into the buffer pool, this must be <= MEM_MAX_ALLOC_IN_BUF
UNIV_INLINE char* mem_strdup ( const char *  str)

Duplicates a NUL-terminated string.

Returns
own: a copy of the string, must be deallocated with mem_free
Parameters
strin: string to be copied
UNIV_INLINE char* mem_strdupl ( const char *  str,
ulint  len 
)

Makes a NUL-terminated copy of a nonterminated string.

Returns
own: a copy of the string, must be deallocated with mem_free
Parameters
strin: string to be copied
lenin: length of str, in bytes

Variable Documentation

block = UT_LIST_GET_LAST(heap->base)

< in: file name where freed