~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to storage/innobase/include/mem0pool.h

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
The lowest-level memory management
 
3
 
 
4
(c) 1994, 1995 Innobase Oy
 
5
 
 
6
Created 6/9/1994 Heikki Tuuri
 
7
*******************************************************/
 
8
 
 
9
#ifndef mem0pool_h
 
10
#define mem0pool_h
 
11
 
 
12
#include "univ.i"
 
13
#include "os0file.h"
 
14
#include "ut0lst.h"
 
15
 
 
16
typedef struct mem_area_struct  mem_area_t;
 
17
typedef struct mem_pool_struct  mem_pool_t;
 
18
 
 
19
/* The common memory pool */
 
20
extern mem_pool_t*      mem_comm_pool;
 
21
 
 
22
/* Memory area header */
 
23
 
 
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 */
 
31
};
 
32
 
 
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),\
 
35
                        UNIV_MEM_ALIGNMENT))
 
36
 
 
37
/************************************************************************
 
38
Creates a memory pool. */
 
39
 
 
40
mem_pool_t*
 
41
mem_pool_create(
 
42
/*============*/
 
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
 
47
used in mem0mem.*! */
 
48
 
 
49
void*
 
50
mem_area_alloc(
 
51
/*===========*/
 
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. */
 
59
 
 
60
void
 
61
mem_area_free(
 
62
/*==========*/
 
63
        void*           ptr,    /* in, own: pointer to allocated memory
 
64
                                buffer */
 
65
        mem_pool_t*     pool);  /* in: memory pool */
 
66
/************************************************************************
 
67
Returns the amount of reserved memory. */
 
68
 
 
69
ulint
 
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. */
 
76
 
 
77
void
 
78
mem_pool_mutex_enter(void);
 
79
/*======================*/
 
80
/************************************************************************
 
81
Releases the mem pool mutex. */
 
82
 
 
83
void
 
84
mem_pool_mutex_exit(void);
 
85
/*=====================*/
 
86
/************************************************************************
 
87
Validates a memory pool. */
 
88
 
 
89
ibool
 
90
mem_pool_validate(
 
91
/*==============*/
 
92
                                /* out: TRUE if ok */
 
93
        mem_pool_t*     pool);  /* in: memory pool */
 
94
/************************************************************************
 
95
Prints info of a memory pool. */
 
96
 
 
97
void
 
98
mem_pool_print_info(
 
99
/*================*/
 
100
        FILE*           outfile,/* in: output file to write to */
 
101
        mem_pool_t*     pool);  /* in: memory pool */
 
102
 
 
103
 
 
104
#ifndef UNIV_NONINL
 
105
#include "mem0pool.ic"
 
106
#endif
 
107
 
 
108
#endif