heap_foreach_free_block.c 823 B

1234567891011121314151617181920212223242526
  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,
  9. void *arg)
  10. {
  11. lub_heap_block_t *block = lub_bintree_findfirst(&this->free_tree);
  12. lub_bintree_iterator_t iter;
  13. unsigned int i = 1;
  14. for(lub_bintree_iterator_init(&iter,&this->free_tree,block);
  15. block;
  16. block = lub_bintree_iterator_next(&iter))
  17. {
  18. /* call the client function */
  19. fn(&block->free,
  20. i++,
  21. (block->free.tag.words << 2) - sizeof(lub_heap_alloc_block_t),
  22. arg);
  23. }
  24. }
  25. /*--------------------------------------------------------- */