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

Go to the source code of this file.

Functions

 ZERO_SIZED (nullalloc)
 An allocator for the standard allocator, which only has global state,.
static nullalloc get ()
static void * malloc (nullalloc *self, size_t size)
static void * realloc (nullalloc *self, void *ptr, size_t size)
static void * calloc (nullalloc *self, size_t count, size_t size)
static void free (nullalloc *self, void *ptr)
 TRAIT_ALLOC (nullalloc)

Function Documentation

◆ calloc()

void * calloc ( nullalloc * self,
size_t count,
size_t size )
static

Definition at line 28 of file null.h.

28 {
29 (void)count;
30 (void)size;
31 ASSUME(self);
32 return NULL;
33}
static INDEX_TYPE size(SELF const *self)
Definition template.h:275
#define ASSUME(expr,...)
Definition macros.h:62
Here is the call graph for this function:

◆ free()

void free ( nullalloc * self,
void * ptr )
static

Definition at line 35 of file null.h.

35 {
36 (void)ptr;
37 ASSUME(self);
38 PANIC("Not possible to free memory from the null allocator, as it allocates nothing")
39}
#define PANIC(...)
Definition macros.h:34
Here is the call graph for this function:

◆ get()

nullalloc get ( )
static

Definition at line 13 of file null.h.

13{ return (nullalloc){}; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ malloc()

void * malloc ( nullalloc * self,
size_t size )
static

Definition at line 15 of file null.h.

15 {
16 (void)size;
17 ASSUME(self);
18 return NULL;
19}
Here is the call graph for this function:

◆ realloc()

void * realloc ( nullalloc * self,
void * ptr,
size_t size )
static

Definition at line 21 of file null.h.

21 {
22 (void)size;
23 ASSUME(self);
24 ASSUME(ptr);
25 return NULL;
26}
Here is the call graph for this function:

◆ TRAIT_ALLOC()

TRAIT_ALLOC ( nullalloc )

◆ ZERO_SIZED()

ZERO_SIZED ( nullalloc )

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