Skip to content

berkaysahiin/mem_alloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

mem_alloc()

This is an implementation of stdlib malloc. Heap is an array of uintptr_t. There is also a garbage collector which frees unreachable chunks of allocated memory.

void* mem_alloc(size_t size_bytes) Allocates memory on heap in words. (Padding is done automatically.)

void mem_free(void* ptr) Frees memory if its allocated.

void merge_fragments() : Merge fragmented memory. This is called at every mem_alloc().

void heap_collect() : Frees unreachable chunks of allocated memory. This should be called by user.


Limitations

  • No packed structures
  • No tricks that obscure the pointers

I followed Tsoding's "Artifacts of that Memory Management Tsoding Session" tutorial so this repository is very much identical to his one:

Other resources that might be helpful:

About

This is an implementation of malloc

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages