moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Mon Oct 16, 2006 5:33 am Post subject: Patch to add Kernel Heap Functions to pspsysmem_kernel.h |
|
|
This is a patch to add the prototypes of some heap functions of SysMemForKernel (sceKernelCreateHeap, sceKernelDeleteHeap, sceKernelAllocHeapMemory, sceKernelFreeHeapMemory, sceKernelHeapTotalFreeSize).
http://moonlight.lan.st/heap.patch
The usage is very easy and intuitive, anyways an example:
| Code: |
// 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
...
}
|
|
|