Derive-C
Loading...
Searching...
No Matches
null.h File Reference
#include <derive-c/core.h>
#include <derive-c/panic.h>
#include <stdlib.h>
Include dependency graph for null.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  nullalloc
 An allocator for the standard allocator, which only has global state,. More...

Functions

static nullalloc get ()
static void * malloc (nullalloc *DEBUG_UNUSED(self), size_t UNUSED(size))
static void * realloc (nullalloc *DEBUG_UNUSED(self), void *DEBUG_UNUSED(ptr), size_t UNUSED(size))
static void * calloc (nullalloc *DEBUG_UNUSED(self), size_t UNUSED(count), size_t UNUSED(size))
static void free (nullalloc *DEBUG_UNUSED(self), void *UNUSED(ptr))

Function Documentation

◆ calloc()

void * calloc ( nullalloc * DEBUG_UNUSEDself,
size_t UNUSEDcount,
size_t UNUSEDsize )
static

Definition at line 34 of file null.h.

35 {
36 DEBUG_ASSERT(self);
37 return NULL;
38}
#define DEBUG_ASSERT(expr)
Definition panic.h:23
Here is the call graph for this function:

◆ free()

void free ( nullalloc * DEBUG_UNUSEDself,
void * UNUSEDptr )
static

Definition at line 40 of file null.h.

40 {
41 DEBUG_ASSERT(self);
42 PANIC("Not possible to free memory from the null allocator, as it allocates nothing")
43}
#define PANIC(...)
Definition panic.h:8
Here is the call graph for this function:

◆ get()

nullalloc get ( )
static

Definition at line 20 of file null.h.

20{ return (nullalloc){}; }
An allocator for the standard allocator, which only has global state,.
Definition null.h:16
Here is the call graph for this function:
Here is the caller graph for this function:

◆ malloc()

void * malloc ( nullalloc * DEBUG_UNUSEDself,
size_t UNUSEDsize )
static

Definition at line 22 of file null.h.

22 {
23 DEBUG_ASSERT(self);
24 return NULL;
25}
Here is the call graph for this function:

◆ realloc()

void * realloc ( nullalloc * DEBUG_UNUSEDself,
void * DEBUG_UNUSEDptr,
size_t UNUSEDsize )
static

Definition at line 27 of file null.h.

28 {
29 DEBUG_ASSERT(self);
30 DEBUG_ASSERT(ptr);
31 return NULL;
32}
Here is the call graph for this function: