heap_foreach_free_block.c 670 B

123456789101112131415161718192021222324
  1. /*
  2. * heap_foreach_free_block.c
  3. */
  4. #include "private.h"
  5. /*--------------------------------------------------------- */
  6. void
  7. lub_heap_foreach_free_block(lub_heap_t * this,
  8. lub_heap_foreach_fn * fn, void *arg)
  9. {
  10. lub_heap_block_t *block = lub_bintree_findfirst(&this->free_tree);
  11. lub_bintree_iterator_t iter;
  12. unsigned int i = 1;
  13. for (lub_bintree_iterator_init(&iter, &this->free_tree, block);
  14. block; block = lub_bintree_iterator_next(&iter)) {
  15. /* call the client function */
  16. fn(&block->free,
  17. i++,
  18. (block->free.tag.words << 2) -
  19. sizeof(lub_heap_alloc_block_t), arg);
  20. }
  21. }
  22. /*--------------------------------------------------------- */