Subastra
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
memory.h File Reference
#include <alloca.h>
#include <string.h>
#include "defs.h"
Include dependency graph for memory.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  allocator_t
 A generic allocator type passed by value. Contains a fallback allocator and a set of function pointers for managing memory. Erases the type of the internal allocator. More...
 

Macros

#define poison_memory_region(ptr, sz)
 If compiled with a memory sanitizer, any write to the brief selected memory will crash the program. If applied multiple times will still only be lifted once. Idempotent. Pair of unpoison_memory_region. O(1)
 
#define unpoison_memory_region(ptr, sz)
 Makes previously poisoned memory safe again. Idemponent. Pair of poison_memory_region. O(1)
 

Typedefs

typedef void * allocator_ptr
 Opaque type-erased pointer to an allocator. Carries no value other than marking an argument to the function as being a type-erased allocator.
 
typedef void *() mem_alloc_f(allocator_ptr allocator, sz size)
 Allocate size bytes using the allocator
 
typedef void *() mem_realloc_f(allocator_ptr allocator, void *memory, sz new_size)
 Reallocate the memory at memory to a new location with.
 
typedef void() mem_free_f(allocator_ptr allocator, void *memory)
 Give up the ownership of the memory within the allocator.
 
typedef struct allocator_t allocator_t
 A generic allocator type passed by value. Contains a fallback allocator and a set of function pointers for managing memory. Erases the type of the internal allocator.
 

Functions

static allocator_t allocator_new_malloc ()
 Wrap malloc into an generic allocator interface.
 
static void * alloc_stack_alloc__alloc (allocator_ptr allocator, sz new_size)
 
static allocator_t allocator_new_stack_alloc ()
 

Macro Definition Documentation

◆ poison_memory_region

#define poison_memory_region (   ptr,
  sz 
)

If compiled with a memory sanitizer, any write to the brief selected memory will crash the program. If applied multiple times will still only be lifted once. Idempotent. Pair of unpoison_memory_region. O(1)

◆ unpoison_memory_region

#define unpoison_memory_region (   ptr,
  sz 
)

Makes previously poisoned memory safe again. Idemponent. Pair of poison_memory_region. O(1)

Typedef Documentation

◆ allocator_ptr

typedef void* allocator_ptr

Opaque type-erased pointer to an allocator. Carries no value other than marking an argument to the function as being a type-erased allocator.

◆ allocator_t

typedef struct allocator_t allocator_t

A generic allocator type passed by value. Contains a fallback allocator and a set of function pointers for managing memory. Erases the type of the internal allocator.

◆ mem_alloc_f

typedef void *() mem_alloc_f(allocator_ptr allocator, sz size)

Allocate size bytes using the allocator

◆ mem_free_f

typedef void() mem_free_f(allocator_ptr allocator, void *memory)

Give up the ownership of the memory within the allocator.

◆ mem_realloc_f

typedef void *() mem_realloc_f(allocator_ptr allocator, void *memory, sz new_size)

Reallocate the memory at memory to a new location with.

Function Documentation

◆ alloc_stack_alloc__alloc()

static void * alloc_stack_alloc__alloc ( allocator_ptr  allocator,
sz  new_size 
)
static

◆ allocator_new_malloc()

static allocator_t allocator_new_malloc ( )
static

Wrap malloc into an generic allocator interface.

◆ allocator_new_stack_alloc()

static allocator_t allocator_new_stack_alloc ( )
static