blob: 17d83d13709ace5722d9ff69319784095e66f752 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/* -------------------------------------------
Copyright Amlal El Mahrouss.
Purpose: DDK allocator.
------------------------------------------- */
#include <DDKKit/ddk.h>
/**
\brief Allocates a new heap on the Kernel's side.
\param sz the size of the heap block.
\return the newly allocated pointer.
*/
DDK_EXTERN void* kalloc(size_t sz)
{
if (!sz)
++sz;
void* ptr = ke_call("mm_new_heap", 1, &sz, sizeof(size_t));
return ptr;
}
/**
\brief Frees a pointer from the heap.
\param ptr the pointer to free.
*/
DDK_EXTERN void kfree(void* ptr)
{
if (!ptr)
return;
ke_call("mm_delete_heap", 1, ptr, 0);
}
|