node.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* node.h */
  2. /**********************************************************
  3. * NODE CLASS DEFINTIONS
  4. ********************************************************** */
  5. #define LEAKED_MASK 0x00000001
  6. #define PARTIAL_MASK 0x00000002
  7. #define SCANNED_MASK 0x00000001
  8. struct _lub_heap_node
  9. {
  10. lub_heap_context_t *_context; /* bottom two bits used for leaked, partial flags */
  11. lub_heap_node_t *_next; /* linked list of nodes per context (bottom bit used for scanned mask) */
  12. lub_heap_node_t *prev;
  13. lub_bintree_node_t bt_node;
  14. };
  15. typedef struct _lub_heap_node_key lub_heap_node_key_t;
  16. struct _lub_heap_node_key
  17. {
  18. const lub_heap_node_t *node;
  19. };
  20. /*---------------------------------------------------------
  21. * PUBLIC META DATA
  22. *--------------------------------------------------------- */
  23. /*
  24. * Get the size (in bytes) of an instance of a node object
  25. */
  26. extern size_t
  27. lub_heap_node__get_instanceSize(void);
  28. /*---------------------------------------------------------
  29. * PUBLIC META FUNCTIONS
  30. *--------------------------------------------------------- */
  31. extern void
  32. lub_heap_node_clear(lub_heap_node_t *instance,
  33. void *arg);
  34. extern void
  35. lub_heap_foreach_node(void (*fn)(lub_heap_node_t *, void*),void *arg);
  36. extern void
  37. lub_heap_scan_memory(const void *mem,
  38. size_t size);
  39. /*
  40. * Given a pointer to the start of a data area of a node obtain the
  41. * node reference. Returns NULL if the node is not valid.
  42. */
  43. extern lub_heap_node_t *
  44. lub_heap_node_from_start_of_block_ptr(char *ptr);
  45. extern void
  46. lub_heap_node_initialise(void);
  47. /*---------------------------------------------------------
  48. * PUBLIC METHODS
  49. *--------------------------------------------------------- */
  50. /*
  51. * Given a node return a pointer to the data area allocated.
  52. */
  53. extern char *
  54. lub_heap_node__get_ptr(
  55. const lub_heap_node_t *instance
  56. );
  57. /*
  58. * Given a node return the size of memory that it encapsulates.
  59. */
  60. extern size_t
  61. lub_heap_node__get_size(
  62. const lub_heap_node_t *instance
  63. );
  64. /*
  65. * Given a node return the size of memory overhead that it encapsulates.
  66. */
  67. extern size_t
  68. lub_heap_node__get_overhead(
  69. const lub_heap_node_t *instance
  70. );
  71. /*
  72. * Get a node to remove itself from it's allocation tree
  73. */
  74. extern void
  75. lub_heap_node_fini(
  76. lub_heap_node_t *instance
  77. );
  78. extern void
  79. lub_heap_node_init(
  80. lub_heap_node_t * instance,
  81. lub_heap_context_t * context
  82. );
  83. extern lub_bintree_compare_fn lub_heap_node_compare;
  84. extern lub_bintree_getkey_fn lub_heap_node_getkey;
  85. extern bool_t
  86. lub_heap_node__get_leaked(
  87. const lub_heap_node_t *instance
  88. );
  89. extern bool_t
  90. lub_heap_node__get_partial(
  91. const lub_heap_node_t *instance
  92. );
  93. extern bool_t
  94. lub_heap_node__get_scanned(
  95. const lub_heap_node_t *instance
  96. );
  97. extern void
  98. lub_heap_node__set_leaked(
  99. lub_heap_node_t *instance,
  100. bool_t value
  101. );
  102. extern void
  103. lub_heap_node__set_partial(
  104. lub_heap_node_t *instance,
  105. bool_t value
  106. );
  107. extern void
  108. lub_heap_node__set_scanned(
  109. lub_heap_node_t *instance,
  110. bool_t value
  111. );
  112. extern lub_heap_context_t *
  113. lub_heap_node__get_context(
  114. const lub_heap_node_t *instance
  115. );
  116. extern void
  117. lub_heap_node__set_context(
  118. lub_heap_node_t *instance,
  119. lub_heap_context_t *context
  120. );
  121. extern lub_heap_node_t *
  122. lub_heap_node__get_next(
  123. const lub_heap_node_t *instance
  124. );
  125. extern void
  126. lub_heap_node__set_next(
  127. lub_heap_node_t *instance,
  128. lub_heap_node_t *context
  129. );