memdebug.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef _MEMDEBUG_H_
  2. #define _MEMDEBUG_H_
  3. /*
  4. * Copyright (C) 2009 by egnite GmbH
  5. *
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the copyright holders nor the names of
  18. * contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  31. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * For additional information see http://www.ethernut.de/
  35. *
  36. */
  37. /*
  38. * $Id: memdebug.h 4473 2012-08-20 15:12:45Z haraldkipp $
  39. */
  40. #include <compiler.h>
  41. #include <cfg/memory.h>
  42. #include <stdlib.h>
  43. #include <string.h>
  44. #ifdef NUTDEBUG_HEAP
  45. #define malloc(s) dbg_malloc(s, __FILE__, __LINE__)
  46. #define calloc(n, s) dbg_calloc(n, s, __FILE__, __LINE__)
  47. #define free(p) dbg_free(p, __FILE__, __LINE__)
  48. #define realloc(p, s) dbg_realloc(p, s, __FILE__, __LINE__)
  49. #define strdup(s) dbg_strdup(s, __FILE__, __LINE__)
  50. #endif
  51. extern void *dbg_malloc(size_t len, const char *file, int line);
  52. extern void *dbg_calloc(size_t num, size_t size, const char *file, int line);
  53. extern void dbg_free(void *p, const char *file, int line);
  54. extern void *dbg_realloc(void* ptr, size_t len, const char *file, int line);
  55. extern char *dbg_strdup(const char *str, const char *file, int line);
  56. #endif