1 /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
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, version 2.0,
5    as published by the Free Software Foundation.
6 
7    This program is also distributed with certain software (including
8    but not limited to OpenSSL) that is licensed under separate terms,
9    as designated in a particular file or component or in included license
10    documentation.  The authors of MySQL hereby grant you an additional
11    permission to link the program and your derivative works with the
12    separately licensed software that they have included with MySQL.
13 
14    Without limiting anything contained in the foregoing, this file,
15    which is part of C Driver for MySQL (Connector/C), is also subject to the
16    Universal FOSS Exception, version 1.0, a copy of which can be found at
17    http://oss.oracle.com/licenses/universal-foss-exception.
18 
19    This program is distributed in the hope that it will be useful,
20    but WITHOUT ANY WARRANTY; without even the implied warranty of
21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22    GNU General Public License, version 2.0, for more details.
23 
24    You should have received a copy of the GNU General Public License
25    along with this program; if not, write to the Free Software
26    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
27 
28 /*
29    Data structures for mysys/my_alloc.c (root memory allocator)
30 */
31 
32 #ifndef _my_alloc_h
33 #define _my_alloc_h
34 
35 #define ALLOC_MAX_BLOCK_TO_DROP			4096
36 #define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP	10
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 typedef struct st_used_mem
43 {				   /* struct for once_alloc (block) */
44   struct st_used_mem *next;	   /* Next block in use */
45   unsigned int	left;		   /* memory left in block  */
46   unsigned int	size;		   /* size of block */
47 } USED_MEM;
48 
49 
50 typedef struct st_mem_root
51 {
52   USED_MEM *free;                  /* blocks with free memory in it */
53   USED_MEM *used;                  /* blocks almost without free memory */
54   USED_MEM *pre_alloc;             /* preallocated block */
55   /* if block have less memory it will be put in 'used' list */
56   size_t min_malloc;
57   size_t block_size;               /* initial block size */
58   unsigned int block_num;          /* allocated blocks counter */
59   /*
60      first free block in queue test counter (if it exceed
61      MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
62   */
63   unsigned int first_block_usage;
64 
65   void (*error_handler)(void);
66 } MEM_ROOT;
67 
68 #ifdef  __cplusplus
69 }
70 #endif
71 
72 #endif
73