/* * palloc_first -- returns the first object from the heap. */ uint64_t palloc_first(struct palloc_heap *heap) { uint64_t off_search = UINT64_MAX; struct memory_block m = {0, 0, 0, 0}; heap_foreach_object(heap, pmalloc_search_cb, &off_search, m); if (off_search == UINT64_MAX) return 0; return off_search + sizeof(struct allocation_header); }
/* * palloc_first -- returns the first object from the heap. */ uint64_t palloc_first(struct palloc_heap *heap) { struct memory_block search = MEMORY_BLOCK_NONE; heap_foreach_object(heap, pmalloc_search_cb, &search, MEMORY_BLOCK_NONE); if (MEMORY_BLOCK_IS_NONE(search)) return 0; void *uptr = search.m_ops->get_user_data(&search); return HEAP_PTR_TO_OFF(heap, uptr); }
/* * palloc_next -- returns the next object relative to 'off'. */ uint64_t palloc_next(struct palloc_heap *heap, uint64_t off) { struct memory_block m = memblock_from_offset(heap, off); struct memory_block search = m; heap_foreach_object(heap, pmalloc_search_cb, &search, m); if (MEMORY_BLOCK_IS_NONE(search) || MEMORY_BLOCK_EQUALS(search, m)) return 0; void *uptr = search.m_ops->get_user_data(&search); return HEAP_PTR_TO_OFF(heap, uptr); }
/* * palloc_next -- returns the next object relative to 'off'. */ uint64_t palloc_next(struct palloc_heap *heap, uint64_t off) { struct allocation_header *alloc = ALLOC_GET_HEADER(heap, off); struct memory_block m = get_mblock_from_alloc(heap, alloc); uint64_t off_search = off - ALLOC_OFF; heap_foreach_object(heap, pmalloc_search_cb, &off_search, m); if (off_search == (off - ALLOC_OFF) || off_search == 0 || off_search == UINT64_MAX) return 0; return off_search + sizeof(struct allocation_header); }