Malloc And Free Library

3

SP4CEBAR 2024-11-23 17:25 (Edited)

This library includes subprograms to allow NX's RAM to be utilized more effectively using malloc and free just like in the C programming language.

how to use

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_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:

Malloc And Free.nx | Open in app
2024-11-23 21:05
Malloc And Free.nx | Open in app
2024-11-23 17:25

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


Log in to reply.