mirror of
https://github.com/tailix/libkernaux.git
synced 2025-04-14 17:32:55 -04:00
Main: include/kernaux/malloc.h: Added types and methods
This commit is contained in:
parent
4c0d4d192c
commit
a6ae2ea05c
2 changed files with 64 additions and 2 deletions
|
@ -5,6 +5,21 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct KernAux_Malloc {
|
||||
int foobar;
|
||||
} *KernAux_Malloc;
|
||||
|
||||
struct KernAux_Malloc KernAux_Malloc_create();
|
||||
void KernAux_Malloc_init(KernAux_Malloc malloc);
|
||||
|
||||
void
|
||||
KernAux_Malloc_add_memory_block(KernAux_Malloc malloc, void *ptr, size_t size);
|
||||
|
||||
void *KernAux_Malloc_malloc(KernAux_Malloc malloc, size_t size);
|
||||
void KernAux_Malloc_free (KernAux_Malloc malloc, void *ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
51
src/malloc.c
51
src/malloc.c
|
@ -2,7 +2,54 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <kernaux/assert.h>
|
||||
#include <kernaux/malloc.h>
|
||||
|
||||
__attribute__((unused))
|
||||
static const int foobar = 1;
|
||||
#include <stddef.h>
|
||||
|
||||
struct KernAux_Malloc KernAux_Malloc_create()
|
||||
{
|
||||
struct KernAux_Malloc malloc;
|
||||
KernAux_Malloc_init(&malloc);
|
||||
return malloc;
|
||||
}
|
||||
|
||||
void KernAux_Malloc_init(const KernAux_Malloc malloc)
|
||||
{
|
||||
KERNAUX_ASSERT(malloc);
|
||||
|
||||
(void)malloc;
|
||||
}
|
||||
|
||||
void KernAux_Malloc_add_memory_block(
|
||||
const KernAux_Malloc malloc,
|
||||
void *const ptr,
|
||||
const size_t size
|
||||
) {
|
||||
KERNAUX_ASSERT(malloc);
|
||||
KERNAUX_ASSERT(ptr);
|
||||
KERNAUX_ASSERT(size);
|
||||
|
||||
(void)malloc;
|
||||
(void)ptr;
|
||||
(void)size;
|
||||
}
|
||||
|
||||
void *KernAux_Malloc_malloc(const KernAux_Malloc malloc, size_t size)
|
||||
{
|
||||
KERNAUX_ASSERT(malloc);
|
||||
if (size == 0) return NULL;
|
||||
|
||||
(void)malloc;
|
||||
(void)size;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void KernAux_Malloc_free(const KernAux_Malloc malloc, void *const ptr)
|
||||
{
|
||||
KERNAUX_ASSERT(malloc);
|
||||
|
||||
(void)malloc;
|
||||
(void)ptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue