This commit is contained in:
Niklas Gollenstede
2025-10-31 22:37:36 +01:00
commit 174fe17e89
197 changed files with 79558 additions and 0 deletions

36
kernel/utils/alloc.h Normal file
View File

@@ -0,0 +1,36 @@
// vim: set noet ts=4 sw=4:
/*! \file
* \brief C-style dynamic memory allocation interface
*/
#pragma once
#include "../types.h"
/*! \brief Allocate a memory block
* The memory is not initialized.
*
* \param size Requested size of memory in bytes.
* \return Pointer to memory or `nullptr` on error (no memory available) or if
* size was zero.
* \opt Implement method
*/
extern "C" void *malloc(size_t size);
/*! \brief Free an allocated memory block
*
* \param ptr Pointer to an previously allocated memory block.
* \opt Implement method
*/
extern "C" void free(void *ptr);
/*! \brief Allocate memory for an array of elements
* The memory is set to zero.
*
* \param nmemb Number of elements
* \param size Size of an element in bytes
* \return pointer to the allocated memory or `nullptr` if the request fails
* \opt Implement method
*/
extern "C" void *calloc(size_t nmemb, size_t size);