9
3

my_alloc.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
  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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 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. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. typedef struct st_used_mem
  23. { /* struct for once_alloc (block) */
  24. struct st_used_mem *next; /* Next block in use */
  25. size_t left; /* memory left in block */
  26. size_t size; /* size of block */
  27. } USED_MEM;
  28. typedef struct st_mem_root
  29. {
  30. USED_MEM *free; /* blocks with free memory in it */
  31. USED_MEM *used; /* blocks almost without free memory */
  32. USED_MEM *pre_alloc; /* preallocated block */
  33. /* if block have less memory it will be put in 'used' list */
  34. size_t min_malloc;
  35. size_t block_size; /* initial block size */
  36. unsigned int block_num; /* allocated blocks counter */
  37. /*
  38. first free block in queue test counter (if it exceed
  39. MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
  40. */
  41. unsigned int first_block_usage;
  42. void (*error_handler)(void);
  43. } MEM_ROOT;
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif