heap_post_realloc.c 998 B

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