00001 /* Copyright (C) 2000 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 /* 00018 Data structures for mysys/my_alloc.c (root memory allocator) 00019 */ 00020 00021 #ifndef _my_alloc_h 00022 #define _my_alloc_h 00023 00024 #define ALLOC_MAX_BLOCK_TO_DROP 4096 00025 #define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10 00026 00027 typedef struct st_used_mem 00028 { /* struct for once_alloc (block) */ 00029 struct st_used_mem *next; /* Next block in use */ 00030 unsigned int left; /* memory left in block */ 00031 unsigned int size; /* size of block */ 00032 } USED_MEM; 00033 00034 00035 typedef struct st_mem_root 00036 { 00037 USED_MEM *free; /* blocks with free memory in it */ 00038 USED_MEM *used; /* blocks almost without free memory */ 00039 USED_MEM *pre_alloc; /* preallocated block */ 00040 /* if block have less memory it will be put in 'used' list */ 00041 unsigned int min_malloc; 00042 unsigned int block_size; /* initial block size */ 00043 unsigned int block_num; /* allocated blocks counter */ 00044 /* 00045 first free block in queue test counter (if it exceed 00046 MAX_BLOCK_USAGE_BEFORE_DROP block will be droped in 'used' list) 00047 */ 00048 unsigned int first_block_usage; 00049 00050 void (*error_handler)(void); 00051 } MEM_ROOT; 00052 #endif