fix: xor with not

This commit is contained in:
Renge 2022-03-25 20:50:24 -04:00
parent 660e269bde
commit 748055996a
2 changed files with 11 additions and 13 deletions

View File

@ -3,15 +3,11 @@
int main(int argc, char const *argv[]) {
sf_set_magic(0x0);
size_t sz_w = 8, sz_x = 200, sz_y = 300, sz_z = 4;
/* void *w = */ sf_malloc(sz_w);
void *x = sf_malloc(sz_x);
void *y = sf_malloc(sz_y);
/* void *z = */ sf_malloc(sz_z);
sf_errno = 0;
size_t sz = sizeof(int);
int *x = sf_malloc(sz);
sf_free(y);
sf_free(x);
// sf_show_heap();
*x = 4;
return EXIT_SUCCESS;
}

View File

@ -89,6 +89,7 @@ void *sf_malloc(sf_size_t size)
sf_block *block = split_block(ptr, min_size);
sf_size_t block_size = get_block_size(block->header);
set_entire_header(block, size, block_size, 1, get_prv_alloc(block->header), 0);
// sf_show_block(block);
return block->body.payload;
}
}
@ -254,6 +255,7 @@ void set_entire_header(sf_block *block, sf_size_t paylod_size, sf_size_t block_s
set_block_size(block, block_size);
set_prv_alloc(block, is_prv_alloc);
set_in_qklst(block, is_in_qklst);
// sf_show_block(block);
}
void set_payload_size(sf_block *block, sf_size_t payload_size)
@ -282,7 +284,7 @@ void set_alloc(sf_block *block, sf_size_t is_alloc)
}
else
{
value &= ~alloc;
value &= (~((uint64_t)alloc));
}
set_header(block, value);
// block->header ^= MAGIC;
@ -298,7 +300,7 @@ void set_prv_alloc(sf_block *block, sf_size_t is_prv_allc)
}
else
{
value &= ~prv_alloc;
value &= (~((uint64_t)prv_alloc));
}
set_header(block, value);
// block->header ^= MAGIC;
@ -314,7 +316,7 @@ void set_in_qklst(sf_block *block, sf_size_t is_in_qklst)
}
else
{
value &= ~in_qklst;
value &= (~((uint64_t)in_qklst));
}
set_header(block, value);
// block->header ^= MAGIC;