http://moonlight.lan.st/heap.patch
The usage is very easy and intuitive, anyways an example:
Code: Select all
// Create a 32 KB heap.
int heapid = sceKernelCreateHeap(PSP_MEMORY_PARTITION_KERNEL, 32*1024, 1, "MyHeap");
if (heapid < 0)
{
// Handle error here
...
}
// Allocate a 8 KB buffer from the heap
u8 *mybuffer = (u8 *)sceKernelAllocHeapMemory(heapid, 8192);
if (!mybuffer)
{
// Handle error here
...
}
// Allocate other memory blocks here if you want
...
// Free the 8 KB buffer
if (sceKernelFreeHeapMemory(heapid, mybuffer) < 0)
{
// Handle error here
...
}
// Free other memory blocks here if you allocated them
...
// Delete the heap
if (sceKernelDeleteHeap(heapid) < 0)
{
// Handle error here
...
}