1
/******************************************************
2
The lowest-level memory management
4
(c) 1994, 1995 Innobase Oy
6
Created 6/9/1994 Heikki Tuuri
7
*******************************************************/
16
typedef struct mem_area_struct mem_area_t;
17
typedef struct mem_pool_struct mem_pool_t;
19
/* The common memory pool */
20
extern mem_pool_t* mem_comm_pool;
22
/* Memory area header */
24
struct mem_area_struct{
25
ulint size_and_free; /* memory area size is obtained by
26
anding with ~MEM_AREA_FREE; area in
27
a free list if ANDing with
28
MEM_AREA_FREE results in nonzero */
29
UT_LIST_NODE_T(mem_area_t)
30
free_list; /* free list node */
33
/* Each memory area takes this many extra bytes for control information */
34
#define MEM_AREA_EXTRA_SIZE (ut_calc_align(sizeof(struct mem_area_struct),\
37
/************************************************************************
38
Creates a memory pool. */
43
/* out: memory pool */
44
ulint size); /* in: pool size in bytes */
45
/************************************************************************
46
Allocates memory from a pool. NOTE: This low-level function should only be
52
/* out, own: allocated memory buffer */
53
ulint size, /* in: allocated size in bytes; for optimum
54
space usage, the size should be a power of 2
55
minus MEM_AREA_EXTRA_SIZE */
56
mem_pool_t* pool); /* in: memory pool */
57
/************************************************************************
58
Frees memory to a pool. */
63
void* ptr, /* in, own: pointer to allocated memory
65
mem_pool_t* pool); /* in: memory pool */
66
/************************************************************************
67
Returns the amount of reserved memory. */
70
mem_pool_get_reserved(
71
/*==================*/
72
/* out: reserved mmeory in bytes */
73
mem_pool_t* pool); /* in: memory pool */
74
/************************************************************************
75
Reserves the mem pool mutex. */
78
mem_pool_mutex_enter(void);
79
/*======================*/
80
/************************************************************************
81
Releases the mem pool mutex. */
84
mem_pool_mutex_exit(void);
85
/*=====================*/
86
/************************************************************************
87
Validates a memory pool. */
93
mem_pool_t* pool); /* in: memory pool */
94
/************************************************************************
95
Prints info of a memory pool. */
100
FILE* outfile,/* in: output file to write to */
101
mem_pool_t* pool); /* in: memory pool */
105
#include "mem0pool.ic"