9
3

my_alloc.h 1.8 KB

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