fix: return payload

This commit is contained in:
Renge 2022-03-26 00:41:31 -04:00
parent c2d87a610e
commit b11b8a26e4
2 changed files with 23 additions and 2 deletions

View File

@ -1,7 +1,28 @@
#include <stdio.h> #include <stdio.h>
#include "sfmm.h" #include "sfmm.h"
int main(int argc, char const *argv[]) { int main(int argc, char const *argv[])
{
size_t sz_x = sizeof(int);
void *x1 = sf_malloc(sz_x);
void *x2 = sf_malloc(sz_x);
void *x3 = sf_malloc(sz_x);
void *x4 = sf_malloc(sz_x);
void *x5 = sf_malloc(sz_x);
sf_show_heap();
sf_free(x1);
sf_free(x2);
sf_free(x3);
sf_free(x4);
sf_free(x5);
void *x6 = sf_malloc(sz_x);
sf_show_heap();
sf_free(x6);
sf_show_heap();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -63,7 +63,7 @@ void *sf_malloc(sf_size_t size)
sf_quick_lists[index].length -= 1; sf_quick_lists[index].length -= 1;
sf_quick_lists[index].first = block->body.links.next; sf_quick_lists[index].first = block->body.links.next;
set_entire_header(block, size, get_block_size(block->header), 1, get_prv_alloc(block->header), 0, 0); set_entire_header(block, size, get_block_size(block->header), 1, get_prv_alloc(block->header), 0, 0);
return block; return block->body.payload;
} }
index = get_index(min_size); index = get_index(min_size);