mirror of https://github.com/tailix/libkernaux.git
Main: include/kernaux/malloc.h: Added types and methods
This commit is contained in:
parent
4c0d4d192c
commit
a6ae2ea05c
|
@ -5,6 +5,21 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
51
src/malloc.c
51
src/malloc.c
|
@ -2,7 +2,54 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <kernaux/assert.h>
|
||||||
#include <kernaux/malloc.h>
|
#include <kernaux/malloc.h>
|
||||||
|
|
||||||
__attribute__((unused))
|
#include <stddef.h>
|
||||||
static const int foobar = 1;
|
|
||||||
|
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…
Reference in New Issue