Skip to content

Commit ba79c30

Browse files
committed
mm: Add interface for memory allocating functions
1 parent 66a4606 commit ba79c30

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

kernel/include/mm/memory_alloc.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#ifndef MEMORY_ALLOC_H_ZPNDLSE1
2+
#define MEMORY_ALLOC_H_ZPNDLSE1
3+
4+
#include <types.h>
5+
6+
/**
7+
* Allocate memory of given size and return its starting address.
8+
*
9+
* @param size_t size of the memory to allocate
10+
* @return void * address of the memory. NULL if allocation failed
11+
*/
12+
void * malloc(size_t);
13+
14+
/**
15+
* Reallocate a piece of memory with the new size.
16+
*
17+
* @param void * address of memory to reallocate
18+
* @param size_t size of the new memory
19+
* @return void * address of the newly reallocated memory. NULL if
20+
* reallocation failed.
21+
*/
22+
void * realloc(void *, size_t);
23+
24+
/**
25+
* Allocates memory for the given number of array elements of the given array
26+
* size. The memory is set to 0.
27+
*
28+
* @param size_t size of the array to allocate memory for
29+
* @param size_t size of each array element
30+
* @return void * address of the newly allocated memory. NULL if
31+
* allocation failed.
32+
*/
33+
void * calloc(size_t, size_t);
34+
35+
/**
36+
* Free a piece of allocated memory.
37+
*
38+
* @param void * address of the allocated memory
39+
*/
40+
void free(void *);
41+
42+
#endif /* end of include guard: MEMORY_ALLOC_H_ZPNDLSE1 */

0 commit comments

Comments
 (0)