asterisk_malloc_debug.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2016, Digium, Inc
  5. *
  6. * George Joseph <gjoseph@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. #define _GNU_SOURCE
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include <stdarg.h>
  23. int __ast_asprintf(const char *file, int lineno, const char *func, char **strp, const char *format, ...)
  24. {
  25. va_list ap;
  26. int rc = 0;
  27. va_start(ap, format);
  28. rc = vasprintf(strp, format, ap);
  29. va_end(ap);
  30. return rc;
  31. }
  32. void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func)
  33. {
  34. return calloc(nmemb, size);
  35. }
  36. void __ast_free(void *ptr, const char *file, int lineno, const char *func)
  37. {
  38. free(ptr);
  39. }
  40. void *__ast_malloc(size_t size, const char *file, int lineno, const char *func)
  41. {
  42. return malloc(size);
  43. }
  44. void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const char *func)
  45. {
  46. return realloc(ptr, size);
  47. }
  48. char *__ast_strdup(const char *s, const char *file, int lineno, const char *func)
  49. {
  50. return strdup(s);
  51. }
  52. char *__ast_strndup(const char *s, size_t n, const char *file, int lineno, const char *func)
  53. {
  54. return strndup(s, n);
  55. }
  56. int __ast_vasprintf(char **strp, const char *format, va_list ap, const char *file, int lineno, const char *func)
  57. {
  58. return vasprintf(strp, format, ap);
  59. }