Commit 46a8f555 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

block_Release(): add one more sanity check

parent a2314241
...@@ -99,8 +99,10 @@ void block_Init( block_t *restrict b, void *buf, size_t size ) ...@@ -99,8 +99,10 @@ void block_Init( block_t *restrict b, void *buf, size_t size )
#endif #endif
} }
static void BlockRelease (block_t *block) static void block_generic_Release (block_t *block)
{ {
/* That is always true for blocks allocated with block_Alloc(). */
assert (block->p_start == (unsigned char *)(block + 1));
block_Invalidate (block); block_Invalidate (block);
free (block); free (block);
} }
...@@ -140,7 +142,7 @@ block_t *block_Alloc (size_t size) ...@@ -140,7 +142,7 @@ block_t *block_Alloc (size_t size)
b->p_buffer += BLOCK_PADDING + BLOCK_ALIGN - 1; b->p_buffer += BLOCK_PADDING + BLOCK_ALIGN - 1;
b->p_buffer = (void *)(((uintptr_t)b->p_buffer) & ~(BLOCK_ALIGN - 1)); b->p_buffer = (void *)(((uintptr_t)b->p_buffer) & ~(BLOCK_ALIGN - 1));
b->i_buffer = size; b->i_buffer = size;
b->pf_release = BlockRelease; b->pf_release = block_generic_Release;
return b; return b;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment