Derive-C
Loading...
Searching...
No Matches
null.h File Reference
#include <derive-c/core/helpers.h>
#include <derive-c/core/panic.h>
#include <stdlib.h>
Include dependency graph for null.h:

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 33 of file null.h.

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

◆ free()

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

Definition at line 39 of file null.h.

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

◆ get()

nullalloc get ( )
static

Definition at line 19 of file null.h.

19{ return (nullalloc){}; }
An allocator for the standard allocator, which only has global state,.
Definition null.h:15
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 21 of file null.h.

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

◆ realloc()

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

Definition at line 26 of file null.h.

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