root/src/mysql/my_alloc.h @ 23

Revision 1, 1.9 kB (checked in by jinshiro, 17 years ago)
Line 
1/* Copyright (C) 2000 MySQL AB
2
3   This program is free software; you can redistribute it and/or modify
4   it under the terms of the GNU General Public License as published by
5   the Free Software Foundation; either version 2 of the License, or
6   (at your option) any later version.
7
8   This program is distributed in the hope that it will be useful,
9   but WITHOUT ANY WARRANTY; without even the implied warranty of
10   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   GNU General Public License for more details.
12
13   You should have received a copy of the GNU General Public License
14   along with this program; if not, write to the Free Software
15   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
16
17/*
18   Data structures for mysys/my_alloc.c (root memory allocator)
19*/
20
21#ifndef _my_alloc_h
22#define _my_alloc_h
23
24#define ALLOC_MAX_BLOCK_TO_DROP                 4096
25#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP       10
26
27typedef struct st_used_mem
28{                                  /* struct for once_alloc (block) */
29  struct st_used_mem *next;        /* Next block in use */
30  unsigned int  left;              /* memory left in block  */
31  unsigned int  size;              /* size of block */
32} USED_MEM;
33
34
35typedef struct st_mem_root
36{
37  USED_MEM *free;                  /* blocks with free memory in it */
38  USED_MEM *used;                  /* blocks almost without free memory */
39  USED_MEM *pre_alloc;             /* preallocated block */
40  /* if block have less memory it will be put in 'used' list */
41  unsigned int min_malloc;
42  unsigned int block_size;         /* initial block size */
43  unsigned int block_num;          /* allocated blocks counter */
44  /*
45     first free block in queue test counter (if it exceed
46     MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
47  */
48  unsigned int first_block_usage;
49
50  void (*error_handler)(void);
51} MEM_ROOT;
52#endif
Note: See TracBrowser for help on using the browser.