heap_block_getprevious.c 686 B

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