node.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. lub_heap_context_t *_context; /* bottom two bits used for leaked, partial flags */
  10. lub_heap_node_t *_next; /* linked list of nodes per context (bottom bit used for scanned mask) */
  11. lub_heap_node_t *prev;
  12. lub_bintree_node_t bt_node;
  13. };
  14. typedef struct _lub_heap_node_key lub_heap_node_key_t;
  15. struct _lub_heap_node_key {
  16. const lub_heap_node_t *node;
  17. };
  18. /*---------------------------------------------------------
  19. * PUBLIC META DATA
  20. *--------------------------------------------------------- */
  21. /*
  22. * Get the size (in bytes) of an instance of a node object
  23. */
  24. extern size_t lub_heap_node__get_instanceSize(void);
  25. /*---------------------------------------------------------
  26. * PUBLIC META FUNCTIONS
  27. *--------------------------------------------------------- */
  28. extern void lub_heap_node_clear(lub_heap_node_t * instance, void *arg);
  29. extern void
  30. lub_heap_foreach_node(void (*fn) (lub_heap_node_t *, void *), void *arg);
  31. extern void lub_heap_scan_memory(const void *mem, size_t size);
  32. /*
  33. * Given a pointer to the start of a data area of a node obtain the
  34. * node reference. Returns NULL if the node is not valid.
  35. */
  36. extern lub_heap_node_t *lub_heap_node_from_start_of_block_ptr(char *ptr);
  37. extern void lub_heap_node_initialise(void);
  38. /*---------------------------------------------------------
  39. * PUBLIC METHODS
  40. *--------------------------------------------------------- */
  41. /*
  42. * Given a node return a pointer to the data area allocated.
  43. */
  44. extern char *lub_heap_node__get_ptr(const lub_heap_node_t * instance);
  45. /*
  46. * Given a node return the size of memory that it encapsulates.
  47. */
  48. extern size_t lub_heap_node__get_size(const lub_heap_node_t * instance);
  49. /*
  50. * Given a node return the size of memory overhead that it encapsulates.
  51. */
  52. extern size_t lub_heap_node__get_overhead(const lub_heap_node_t * instance);
  53. /*
  54. * Get a node to remove itself from it's allocation tree
  55. */
  56. extern void lub_heap_node_fini(lub_heap_node_t * instance);
  57. extern void
  58. lub_heap_node_init(lub_heap_node_t * instance, lub_heap_context_t * context);
  59. extern lub_bintree_compare_fn lub_heap_node_compare;
  60. extern lub_bintree_getkey_fn lub_heap_node_getkey;
  61. extern bool_t lub_heap_node__get_leaked(const lub_heap_node_t * instance);
  62. extern bool_t lub_heap_node__get_partial(const lub_heap_node_t * instance);
  63. extern bool_t lub_heap_node__get_scanned(const lub_heap_node_t * instance);
  64. extern void lub_heap_node__set_leaked(lub_heap_node_t * instance, bool_t value);
  65. extern void
  66. lub_heap_node__set_partial(lub_heap_node_t * instance, bool_t value);
  67. extern void
  68. lub_heap_node__set_scanned(lub_heap_node_t * instance, bool_t value);
  69. extern lub_heap_context_t *lub_heap_node__get_context(const lub_heap_node_t *
  70. instance);
  71. extern void
  72. lub_heap_node__set_context(lub_heap_node_t * instance,
  73. lub_heap_context_t * context);
  74. extern lub_heap_node_t *lub_heap_node__get_next(const lub_heap_node_t *
  75. instance);
  76. extern void
  77. lub_heap_node__set_next(lub_heap_node_t * instance, lub_heap_node_t * context);