~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2008-12-06 22:41:03 UTC
  • mto: (656.1.7 devel)
  • mto: This revision was merged to the branch mainline in revision 665.
  • Revision ID: monty@inaugust.com-20081206224103-jdouqwt9hb0f01y1
Moved non-working tests into broken suite for easier running of working tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 
3
 
Copyright (C) 1994, 2009, Innobase Oy. All Rights Reserved.
4
 
 
5
 
This program is free software; you can redistribute it and/or modify it under
6
 
the terms of the GNU General Public License as published by the Free Software
7
 
Foundation; version 2 of the License.
8
 
 
9
 
This program is distributed in the hope that it will be useful, but WITHOUT
10
 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
 
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
 
 
13
 
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
 
St, Fifth Floor, Boston, MA 02110-1301 USA
16
 
 
17
 
*****************************************************************************/
18
 
 
19
 
/**************************************************//**
20
 
@file include/mem0pool.h
 
1
/******************************************************
21
2
The lowest-level memory management
22
3
 
 
4
(c) 1994, 1995 Innobase Oy
 
5
 
23
6
Created 6/9/1994 Heikki Tuuri
24
7
*******************************************************/
25
8
 
30
13
#include "os0file.h"
31
14
#include "ut0lst.h"
32
15
 
33
 
/** Memory area header */
34
16
typedef struct mem_area_struct  mem_area_t;
35
 
/** Memory pool */
36
17
typedef struct mem_pool_struct  mem_pool_t;
37
18
 
38
 
/** The common memory pool */
 
19
/* The common memory pool */
39
20
extern mem_pool_t*      mem_comm_pool;
40
21
 
41
 
/** Memory area header */
 
22
/* Memory area header */
42
23
 
43
24
struct mem_area_struct{
44
 
        ulint           size_and_free;  /*!< memory area size is obtained by
 
25
        ulint           size_and_free;  /* memory area size is obtained by
45
26
                                        anding with ~MEM_AREA_FREE; area in
46
27
                                        a free list if ANDing with
47
28
                                        MEM_AREA_FREE results in nonzero */
48
29
        UT_LIST_NODE_T(mem_area_t)
49
 
                        free_list;      /*!< free list node */
 
30
                        free_list;      /* free list node */
50
31
};
51
32
 
52
 
/** Each memory area takes this many extra bytes for control information */
 
33
/* Each memory area takes this many extra bytes for control information */
53
34
#define MEM_AREA_EXTRA_SIZE     (ut_calc_align(sizeof(struct mem_area_struct),\
54
35
                        UNIV_MEM_ALIGNMENT))
55
36
 
56
 
/********************************************************************//**
57
 
Creates a memory pool.
58
 
@return memory pool */
 
37
/************************************************************************
 
38
Creates a memory pool. */
59
39
UNIV_INTERN
60
40
mem_pool_t*
61
41
mem_pool_create(
62
42
/*============*/
63
 
        ulint   size);  /*!< in: pool size in bytes */
64
 
/********************************************************************//**
65
 
Frees a memory pool. */
66
 
UNIV_INTERN
67
 
void
68
 
mem_pool_free(
69
 
/*==========*/
70
 
        mem_pool_t*     pool);  /*!< in, own: memory pool */
71
 
/********************************************************************//**
 
43
                        /* out: memory pool */
 
44
        ulint   size);  /* in: pool size in bytes */
 
45
/************************************************************************
72
46
Allocates memory from a pool. NOTE: This low-level function should only be
73
 
used in mem0mem.*!
74
 
@return own: allocated memory buffer */
 
47
used in mem0mem.*! */
75
48
UNIV_INTERN
76
49
void*
77
50
mem_area_alloc(
78
51
/*===========*/
79
 
        ulint*          psize,  /*!< in: requested size in bytes; for optimum
 
52
                                /* out, own: allocated memory buffer */
 
53
        ulint*          psize,  /* in: requested size in bytes; for optimum
80
54
                                space usage, the size should be a power of 2
81
55
                                minus MEM_AREA_EXTRA_SIZE;
82
56
                                out: allocated size in bytes (greater than
83
57
                                or equal to the requested size) */
84
 
        mem_pool_t*     pool);  /*!< in: memory pool */
85
 
/********************************************************************//**
 
58
        mem_pool_t*     pool);  /* in: memory pool */
 
59
/************************************************************************
86
60
Frees memory to a pool. */
87
61
UNIV_INTERN
88
62
void
89
63
mem_area_free(
90
64
/*==========*/
91
 
        void*           ptr,    /*!< in, own: pointer to allocated memory
 
65
        void*           ptr,    /* in, own: pointer to allocated memory
92
66
                                buffer */
93
 
        mem_pool_t*     pool);  /*!< in: memory pool */
94
 
/********************************************************************//**
95
 
Returns the amount of reserved memory.
96
 
@return reserved mmeory in bytes */
 
67
        mem_pool_t*     pool);  /* in: memory pool */
 
68
/************************************************************************
 
69
Returns the amount of reserved memory. */
97
70
UNIV_INTERN
98
71
ulint
99
72
mem_pool_get_reserved(
100
73
/*==================*/
101
 
        mem_pool_t*     pool);  /*!< in: memory pool */
102
 
/********************************************************************//**
103
 
Validates a memory pool.
104
 
@return TRUE if ok */
 
74
                                /* out: reserved mmeory in bytes */
 
75
        mem_pool_t*     pool);  /* in: memory pool */
 
76
/************************************************************************
 
77
Reserves the mem pool mutex. */
 
78
UNIV_INTERN
 
79
void
 
80
mem_pool_mutex_enter(void);
 
81
/*======================*/
 
82
/************************************************************************
 
83
Releases the mem pool mutex. */
 
84
UNIV_INTERN
 
85
void
 
86
mem_pool_mutex_exit(void);
 
87
/*=====================*/
 
88
/************************************************************************
 
89
Validates a memory pool. */
105
90
UNIV_INTERN
106
91
ibool
107
92
mem_pool_validate(
108
93
/*==============*/
109
 
        mem_pool_t*     pool);  /*!< in: memory pool */
110
 
/********************************************************************//**
 
94
                                /* out: TRUE if ok */
 
95
        mem_pool_t*     pool);  /* in: memory pool */
 
96
/************************************************************************
111
97
Prints info of a memory pool. */
112
98
UNIV_INTERN
113
99
void
114
100
mem_pool_print_info(
115
101
/*================*/
116
 
        FILE*           outfile,/*!< in: output file to write to */
117
 
        mem_pool_t*     pool);  /*!< in: memory pool */
 
102
        FILE*           outfile,/* in: output file to write to */
 
103
        mem_pool_t*     pool);  /* in: memory pool */
118
104
 
119
105
 
120
106
#ifndef UNIV_NONINL