2021-05-01, 07:07 PM
2021-04-21: Dynamic Memory Allocation
Using YSI you can allocate and free memory when you like (and as much as you like):
Using YSI you can allocate and free memory when you like (and as much as you like):
Quote:
func(arr[], size)
{
____for (new i = 0; i != size; ) printf("%d", arr[i]);
}
main()
{
____new Alloc:a = malloc(1000); // Allocate 1000 cells.
____mset(a, 0, 50); // Write "50" to the first slot.
____// Pass our newly allocated array to a function.
____func(mget(a, 0), Malloc_SlotSize(a));
____// Free the memory (or we will eventually run out).
____free(a);
}