mm.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* mm.h - prototypes and declarations for memory manager */
  2. /*
  3. * GRUB -- GRand Unified Bootloader
  4. * Copyright (C) 2002,2007 Free Software Foundation, Inc.
  5. *
  6. * GRUB is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * GRUB is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef GRUB_MM_H
  20. #define GRUB_MM_H 1
  21. #include <grub/types.h>
  22. #include <grub/symbol.h>
  23. #include <config.h>
  24. #ifndef NULL
  25. # define NULL ((void *) 0)
  26. #endif
  27. void grub_mm_init_region (void *addr, grub_size_t size);
  28. void *grub_malloc (grub_size_t size);
  29. void *grub_zalloc (grub_size_t size);
  30. void grub_free (void *ptr);
  31. void *grub_realloc (void *ptr, grub_size_t size);
  32. void *grub_memalign (grub_size_t align, grub_size_t size);
  33. grub_size_t grub_mm_get_free (void);
  34. /* For debugging. */
  35. #if defined(MM_DEBUG) && !defined(GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
  36. /* Set this variable to 1 when you want to trace all memory function calls. */
  37. extern int grub_mm_debug;
  38. void grub_mm_dump_free (void);
  39. void grub_mm_dump (unsigned lineno);
  40. #define grub_malloc(size) \
  41. grub_debug_malloc (GRUB_FILE, __LINE__, size)
  42. #define grub_zalloc(size) \
  43. grub_debug_zalloc (GRUB_FILE, __LINE__, size)
  44. #define grub_realloc(ptr,size) \
  45. grub_debug_realloc (GRUB_FILE, __LINE__, ptr, size)
  46. #define grub_memalign(align,size) \
  47. grub_debug_memalign (GRUB_FILE, __LINE__, align, size)
  48. #define grub_free(ptr) \
  49. grub_debug_free (GRUB_FILE, __LINE__, ptr)
  50. void *grub_debug_malloc (const char *file, int line,
  51. grub_size_t size);
  52. void *grub_debug_zalloc (const char *file, int line,
  53. grub_size_t size);
  54. void grub_debug_free (const char *file, int line, void *ptr);
  55. void *grub_debug_realloc (const char *file, int line, void *ptr,
  56. grub_size_t size);
  57. void *grub_debug_memalign (const char *file, int line,
  58. grub_size_t align, grub_size_t size);
  59. #endif /* MM_DEBUG && ! GRUB_UTIL */
  60. #endif /* ! GRUB_MM_H */