Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lesson6/my_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ void* my_malloc(size_t size) {
size_t buffer_size = 4096;
simple_metadata_t* metadata =
(simple_metadata_t*)mmap_from_system(buffer_size);
// ALEXNOTE: no error checking - I understand this was the case in the sample code as well
metadata->size = buffer_size - sizeof(simple_metadata_t);
metadata->next = NULL;
// Add the memory region to the free list.
Expand Down Expand Up @@ -240,6 +241,7 @@ void* my_malloc(size_t size) {
// This is called every time an object is freed. You are not allowed to use
// any library functions other than mmap_from_system / munmap_to_system.
void my_free(void* ptr) { simple_free(ptr); }
// ALEXNOTE: food for thought: was there any way to optimize my_free() ?

////////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -555,4 +557,4 @@ int main(int argc, char** argv) {
test();
run_challenges();
return 0;
}
}