InnoDB Plugin
1.0
|
#include "univ.i"
#include "ut0mem.h"
#include "ut0byte.h"
#include "ut0rnd.h"
#include "sync0sync.h"
#include "ut0lst.h"
#include "mach0data.h"
#include "mem0dbg.h"
#include "mem0mem.ic"
Go to the source code of this file.
Data Structures | |
struct | mem_block_info_t |
Macros | |
#define | MEM_HEAP_DYNAMIC 0 /* the most common type */ |
#define | MEM_HEAP_BUFFER 1 |
#define | MEM_HEAP_BTR_SEARCH |
#define | MEM_HEAP_FOR_BTR_SEARCH (MEM_HEAP_BTR_SEARCH | MEM_HEAP_BUFFER) |
#define | MEM_HEAP_FOR_PAGE_HASH (MEM_HEAP_DYNAMIC) |
#define | MEM_HEAP_FOR_RECV_SYS (MEM_HEAP_BUFFER) |
#define | MEM_HEAP_FOR_LOCK_HEAP (MEM_HEAP_BUFFER) |
#define | MEM_BLOCK_START_SIZE 64 |
#define | MEM_BLOCK_STANDARD_SIZE (UNIV_PAGE_SIZE >= 16384 ? 8000 : MEM_MAX_ALLOC_IN_BUF) |
#define | MEM_MAX_ALLOC_IN_BUF (UNIV_PAGE_SIZE - 200) |
#define | mem_heap_create(N) |
#define | mem_heap_create_typed(N, T) |
#define | mem_heap_free(heap) |
#define | mem_zalloc(N) memset(mem_alloc(N), 0, (N)) |
#define | mem_alloc(N) mem_alloc_func((N), __FILE__, __LINE__, NULL) |
#define | mem_alloc2(N, S) mem_alloc_func((N), __FILE__, __LINE__, (S)) |
#define | mem_free(PTR) mem_free_func((PTR), __FILE__, __LINE__) |
#define | MEM_BLOCK_MAGIC_N 764741555 |
#define | MEM_FREED_BLOCK_MAGIC_N 547711122 |
#define | MEM_BLOCK_HEADER_SIZE |
Typedefs | |
typedef struct mem_block_info_t | mem_block_t |
typedef mem_block_t | mem_heap_t |
Functions | |
UNIV_INTERN void | mem_init (ulint size) |
UNIV_INTERN void | mem_close (void) |
UNIV_INLINE mem_heap_t * | mem_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, ulint line) |
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 ulint | mem_heap_get_size (mem_heap_t *heap) |
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 char * | mem_strdup (const char *str) |
UNIV_INLINE char * | mem_strdupl (const char *str, ulint len) |
UNIV_INTERN char * | mem_heap_strdup (mem_heap_t *heap, const char *str) |
UNIV_INLINE char * | mem_heap_strdupl (mem_heap_t *heap, const char *str, ulint len) |
UNIV_INTERN char * | mem_heap_strcat (mem_heap_t *heap, const char *s1, const char *s2) |
UNIV_INTERN void * | mem_heap_dup (mem_heap_t *heap, const void *data, ulint len) |
UNIV_INTERN char * | mem_heap_printf (mem_heap_t *heap, const char *format,...))) |
The memory management
Created 6/9/1994 Heikki Tuuri
#define MEM_BLOCK_HEADER_SIZE |
#define mem_free | ( | PTR | ) | mem_free_func((PTR), __FILE__, __LINE__) |
Use this macro instead of the corresponding function! Macro for memory buffer freeing
#define MEM_HEAP_BTR_SEARCH |
#define mem_heap_create | ( | N | ) |
Use this macro instead of the corresponding function! Macro for memory heap creation.
#define mem_heap_create_typed | ( | N, | |
T | |||
) |
Use this macro instead of the corresponding function! Macro for memory heap creation.
#define mem_heap_free | ( | heap | ) |
Use this macro instead of the corresponding function! Macro for memory heap freeing.
#define mem_zalloc | ( | N | ) | memset(mem_alloc(N), 0, (N)) |
Use this macro instead of the corresponding function! Macro for memory buffer allocation
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.
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.
n | in: desired number of bytes |
file_name | in: file name where created |
line | in: line where created |
size | out: allocated size in bytes, or NULL |
UNIV_INTERN void mem_close | ( | void | ) |
Closes the memory system.
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 C compiler. Similar to free of C. in: line where created
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.
ptr | in, own: buffer to be freed |
file_name | in: file name where created |
line | in: line where created |
UNIV_INLINE void* mem_heap_alloc | ( | mem_heap_t * | heap, |
ulint | n | ||
) |
Allocates n bytes of memory from a memory heap.
Allocates n bytes of memory from a memory heap.
heap | in: memory heap |
n | in: number of bytes; if the heap is allowed to grow into the buffer pool, this must be <= MEM_MAX_ALLOC_IN_BUF |
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 arguments.
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.
n | in: 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_name | in: file name where created |
line | in: line where created |
type | in: heap type |
UNIV_INTERN void* mem_heap_dup | ( | mem_heap_t * | heap, |
const void * | data, | ||
ulint | len | ||
) |
Duplicate a block of data, allocated from a memory heap.
heap | in: memory heap where copy is allocated |
data | in: data to be copied |
UNIV_INLINE void mem_heap_empty | ( | mem_heap_t * | heap | ) |
Empties a memory heap. The first memory block of the heap is not freed. in: heap to empty
Empties a memory heap. The first memory block of the heap is not freed.
heap | in: heap to empty |
UNIV_INLINE void mem_heap_free_func | ( | mem_heap_t * | heap, |
const char * | file_name, | ||
ulint | line | ||
) |
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. in: line where freed
heap | in, own: heap to be freed |
file_name | in: file name where 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. in: pointer to old top of heap
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.
heap | in: heap from which to free |
old_top | in: 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. in: size of the topmost element
Frees the topmost element in a memory heap. The size of the element must be given.
heap | in: memory heap |
n | in: 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 a pointer to the heap top.
heap | in: memory heap |
UNIV_INLINE ulint mem_heap_get_size | ( | mem_heap_t * | heap | ) |
Returns the space in bytes occupied by a memory heap. in: heap
Returns the space in bytes occupied by a memory heap.
heap | in: 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 a pointer to the topmost element in a memory heap. The size of the element must be given.
heap | in: memory heap |
n | in: size of the topmost element |
UNIV_INTERN char* mem_heap_printf | ( | mem_heap_t * | heap, |
const char * | format, | ||
... | |||
) |
A simple sprintf replacement that dynamically allocates the space for the formatted string from the given heap. This supports a very limited set of the printf syntax: types 's' and 'u' and length modifier 'l' (which is required for the 'u' type).
heap | in: memory heap |
format | in: format string |
UNIV_INTERN char* mem_heap_strcat | ( | mem_heap_t * | heap, |
const char * | s1, | ||
const char * | s2 | ||
) |
Concatenate two strings and return the result, using a memory heap.
heap | in: memory heap where string is allocated |
s1 | in: string 1 |
UNIV_INTERN char* mem_heap_strdup | ( | mem_heap_t * | heap, |
const char * | str | ||
) |
Duplicates a NUL-terminated string, allocated from a memory heap.
heap | in: memory heap where string is allocated |
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.
Makes a NUL-terminated copy of a nonterminated string, allocated from a memory heap.
heap | in: memory heap where string is allocated |
str | in: string to be copied |
len | in: 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.
Allocates and zero-fills n bytes of memory from a memory heap.
heap | in: memory heap |
n | in: 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_init | ( | ulint | size | ) |
Initializes the memory system. in: common pool size in bytes
UNIV_INLINE char* mem_strdup | ( | const char * | str | ) |
Duplicates a NUL-terminated string.
Duplicates a NUL-terminated string.
str | in: string to be copied |
UNIV_INLINE char* mem_strdupl | ( | const char * | str, |
ulint | len | ||
) |
Makes a NUL-terminated copy of a nonterminated string.
Makes a NUL-terminated copy of a nonterminated string.
str | in: string to be copied |
len | in: length of str, in bytes |