mtrace_demo.c 396 B

12345678910111213141516171819202122232425
  1. #define DEBUG_MTRACE
  2. #include <stdlib.h> // for malloc
  3. #include <mcheck.h> // for mtrace() / muntrace();
  4. #define LOG_LEVEL 2
  5. #include <syslog.h>
  6. int main(int argc, char **argv)
  7. {
  8. LOG_I("Enter\n");
  9. int ret;
  10. #ifdef DEBUG_MTRACE
  11. mtrace();
  12. #endif
  13. int *tmp = malloc(0x1234);
  14. LOG_I("malloc 0x1234 bytes(%p) without free.\n", tmp);
  15. #ifdef DEBUG_MTRACE
  16. muntrace();
  17. #endif
  18. LOG_I("Exit\n");
  19. }