heap_post_realloc.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <string.h>
  2. #include "private.h"
  3. #include "context.h"
  4. #include "node.h"
  5. void
  6. lub_heap_post_realloc(lub_heap_t *this,
  7. char **ptr)
  8. {
  9. /* only act if we are about to re-enable the monitoring */
  10. if((0 < lub_heap_frame_count) && ( 2 > this->suppress))
  11. {
  12. if(NULL != *ptr)
  13. {
  14. stackframe_t frame;
  15. lub_heap_node_t *node = (lub_heap_node_t*)*ptr;
  16. const lub_heap_context_t *context;
  17. lub_heap__get_stackframe(&frame,lub_heap_frame_count);
  18. /* make sure we break any recursive behaviour */
  19. ++this->suppress;
  20. context = lub_heap_context_find_or_create(this,&frame);
  21. --this->suppress;
  22. /* initialise the node instance */
  23. lub_heap_node_init(node,(lub_heap_context_t*)context);
  24. /* make sure we doctor the pointer given back to the client */
  25. *ptr = lub_heap_node__get_ptr(node);
  26. }
  27. }
  28. }
  29. void
  30. lub_heap_leak_suppress_detection(lub_heap_t *this)
  31. {
  32. ++this->suppress;
  33. }
  34. void
  35. lub_heap_leak_restore_detection(lub_heap_t *this)
  36. {
  37. --this->suppress;
  38. }