my_alloc.h 1.8 KB

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