fix: remove from edge

This commit is contained in:
Renge 2022-03-25 21:51:46 -04:00
parent aff161557e
commit e65ab8192b
2 changed files with 7 additions and 19 deletions

View File

@ -5,26 +5,8 @@ int main(int argc, char const *argv[]) {
sf_set_magic(0x0); sf_set_magic(0x0);
size_t sz_u = 200, sz_v = 150, sz_w = 50, sz_x = 150, sz_y = 200, sz_z = 250; sf_malloc(4032);
void *u = sf_malloc(sz_u);
sf_show_heap();
/* void *v = */ sf_malloc(sz_v);
sf_show_heap();
void *w = sf_malloc(sz_w);
sf_show_heap();
/* void *x = */ sf_malloc(sz_x);
sf_show_heap();
void *y = sf_malloc(sz_y);
sf_show_heap();
/* void *z = */ sf_malloc(sz_z);
sf_show_heap(); sf_show_heap();
sf_free(u);
sf_show_heap();
sf_free(w);
sf_show_heap();
sf_free(y);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -100,6 +100,12 @@ void *sf_malloc(sf_size_t size)
sf_block *last = get_prev_block(epi); sf_block *last = get_prev_block(epi);
if (get_alloc(last->header) == 1) if (get_alloc(last->header) == 1)
last = epi; last = epi;
if (last->body.links.next != NULL)
{
last->body.links.next->body.links.prev = last->body.links.prev;
last->body.links.prev->body.links.next = last->body.links.next;
}
sf_size_t require_size = min_size - get_block_size(last->header); sf_size_t require_size = min_size - get_block_size(last->header);
size_t i = 0; size_t i = 0;
for (; i < require_size; i += 1024) for (; i < require_size; i += 1024)