SP4CEBAR 2024-11-23 17:25 (Edited)
Some data structures have their roots in malloc, so we can now make structures like a linked list more easily.
Here are the main functions
MAL_MALLOC( R_CHUNK_ADDRESS, REQUESTED_CHUNK_SIZE, R_ERROR_CODE )
MAL_FREE( CHUNK_ADDRESS, R_ERROR_CODE )
MAL_INIT_HEAP( HEAP_ADDRESS, HEAP_SIZE )
MAL_LEAK_FINDER
MAL_INIT_HEAP is used to set the heap location and size. It also generates a chunk to fill the heap with "unallocated space". The heap is the memory space in which malloc and free will work. Calling this subprogram is part of the setup subroutine.
MAL_LEAK_FINDER will trace all allocated chunks, it is a bad practice to leave allocated chunks when a program exits, this would cause a memory leak in other programming languages.
Technical details:
SP4CEBAR 2024-11-23 21:06
Update: unallocated-chunk-merging optimization
Sylveon 2024-11-23 22:04
Wow, cool :3
SP4CEBAR 2024-11-29 20:40 (Edited)
This can be used together with my concept of structs, I could even add a SIZEOF() array