heap_leak_mutex.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <pthread.h>
  2. #include <stdio.h>
  3. #include "../private.h"
  4. #include "../context.h"
  5. static pthread_mutex_t leak_mutex = PTHREAD_MUTEX_INITIALIZER;
  6. static lub_heap_leak_t instance;
  7. /*--------------------------------------------------------- */
  8. void
  9. lub_heap_leak_mutex_lock(void)
  10. {
  11. int status = pthread_mutex_lock(&leak_mutex);
  12. if(0 != status)
  13. {
  14. perror("pthread_mutex_lock() failed");
  15. }
  16. }
  17. /*--------------------------------------------------------- */
  18. void
  19. lub_heap_leak_mutex_unlock(void)
  20. {
  21. int status = pthread_mutex_unlock(&leak_mutex);
  22. if(0 != status)
  23. {
  24. perror("pthread_mutex_unlock() failed");
  25. }
  26. }
  27. /*--------------------------------------------------------- */
  28. lub_heap_leak_t *
  29. lub_heap_leak_instance(void)
  30. {
  31. lub_heap_leak_mutex_lock();
  32. return &instance;
  33. }
  34. /*--------------------------------------------------------- */
  35. void
  36. lub_heap_leak_release(lub_heap_leak_t *instance)
  37. {
  38. lub_heap_leak_mutex_unlock();
  39. }
  40. /*--------------------------------------------------------- */
  41. bool_t
  42. lub_heap_leak_query_node_tree(void)
  43. {
  44. return BOOL_TRUE;
  45. }
  46. /*--------------------------------------------------------- */
  47. bool_t
  48. lub_heap_leak_query_clear_node_tree(void)
  49. {
  50. return BOOL_TRUE;
  51. }
  52. /*--------------------------------------------------------- */