heap_block_getprevious.c 764 B

12345678910111213141516171819202122232425
  1. #include "private.h"
  2. /*--------------------------------------------------------- */
  3. lub_heap_block_t *
  4. lub_heap_block_getprevious(lub_heap_block_t *this)
  5. {
  6. lub_heap_block_t *result = NULL;
  7. /* only go back if this is not the first block in the segment */
  8. if(0 == this->alloc.tag.segment)
  9. {
  10. /* get the tag from the previous block */
  11. lub_heap_tag_t *tag = &(&this->alloc.tag)[-1];
  12. /* get a pointer to the previous block
  13. * +1 required to account for header tag
  14. */
  15. tag = &tag[1-tag->words];
  16. /* now point to the start of the previous block */
  17. result = (lub_heap_block_t *)tag;
  18. }
  19. return result;
  20. }
  21. /*--------------------------------------------------------- */