fix: change payload size when realloc
This commit is contained in:
parent
c227704733
commit
507276d82f
|
@ -4,13 +4,10 @@
|
|||
int main(int argc, char const *argv[]) {
|
||||
sf_set_magic(0x0);
|
||||
|
||||
size_t sz_x = sizeof(double) * 8, sz_y = sizeof(int);
|
||||
size_t sz_x = sizeof(int) * 20, sz_y = sizeof(int) * 16;
|
||||
void *x = sf_malloc(sz_x);
|
||||
sf_realloc(x, sz_y);
|
||||
|
||||
// cr_assert_not_null(x, "x is NULL!");
|
||||
// sf_block *bp = (sf_block *)((char *)x - 16);
|
||||
|
||||
|
||||
|
||||
sf_show_heap();
|
||||
|
|
|
@ -180,7 +180,10 @@ void *sf_realloc(void *pp, sf_size_t rsize)
|
|||
else
|
||||
{
|
||||
if (size - new_size < min)
|
||||
{
|
||||
set_entire_header(block, rsize, size, 1, get_prv_alloc(block->header), 0);
|
||||
return block->body.payload;
|
||||
}
|
||||
else
|
||||
{
|
||||
sf_block *ptr = split_block(block, new_size);
|
||||
|
|
Loading…
Reference in New Issue
Block a user