Patch to add Kernel Heap Functions to pspsysmem_kernel.h

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Patch to add Kernel Heap Functions to pspsysmem_kernel.h

Post by moonlight »

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: Select all

// Create a 32 KB heap.
int heapid = sceKernelCreateHeap(PSP_MEMORY_PARTITION_KERNEL, 32*1024,  1, "MyHeap");

if &#40;heapid < 0&#41;
&#123;
    // Handle error here
   ...
&#125;

// Allocate a 8 KB buffer from the heap
u8 *mybuffer = &#40;u8 *&#41;sceKernelAllocHeapMemory&#40;heapid, 8192&#41;;
if &#40;!mybuffer&#41;
&#123;
   // Handle error here
  ...
&#125;

// Allocate other memory blocks here if you want
...

// Free the 8 KB buffer
if &#40;sceKernelFreeHeapMemory&#40;heapid, mybuffer&#41; < 0&#41;
&#123;
   // Handle error here
   ...
&#125;

// Free other memory blocks here if you allocated them
...

// Delete the heap
if &#40;sceKernelDeleteHeap&#40;heapid&#41; < 0&#41;
&#123;
   // Handle error here
   ...
&#125;

TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

committed
Post Reply