coan 4.2.4
The Memory component interface.
Collaboration diagram for The Memory component interface.:

Files

file  memory.c
file  memory.h

Typedefs

typedef char * heap_str
typedef char const * heap_str_const

Functions

void * allocate (size_t bytes)
void * zallocate (size_t bytes)
void * reallocate (void *ptr, size_t bytes)
void * callocate (size_t items, size_t size)
void release (void **pp)
void * clone (void const *src, size_t len)

Typedef Documentation

typedef char* heap_str

Type to represent non-const strings allocated on the heap

Definition at line 52 of file memory.h.

typedef char const* heap_str_const

Type to represent const strings allocated on the heap

Definition at line 55 of file memory.h.


Function Documentation

void* allocate ( size_t  bytes)

malloc() wrapper; bails on failure

Definition at line 68 of file memory.c.

References no_alloc_fail().

Referenced by canonical_string_copy(), clone(), file_tree_copy(), file_tree_new(), ptr_set_copy(), and ptr_set_new().

Here is the call graph for this function:

void* callocate ( size_t  items,
size_t  size 
)

calloc() wrapper; bails on failure

Definition at line 87 of file memory.c.

References no_alloc_fail().

Referenced by concatenate(), file_tree_name(), file_tree_traverse(), and new_node().

Here is the call graph for this function:

void* clone ( void const *  src,
size_t  len 
)

Copy a region of memory into a heap block.

Parameters:
srcAddress of the region to copy.
lenLength of the region to copy in bytes, or 0. If 0 then the 0-terminated array of characters at src is copied.
Returns:
Pointer to a heap block containing the copied bytes. If src is NULL then NULL is returned.

The returned heap block has always a terminal 0.

Definition at line 101 of file memory.c.

References allocate().

Referenced by canonical_string_copy_init(), canonical_string_init(), canonical_string_substr(), default_cloner(), file_tree_copy_init(), format_int(), get_line(), symbol_copy_init(), symbol_init(), and symbol_resolve().

Here is the call graph for this function:

void* reallocate ( void *  ptr,
size_t  bytes 
)

realloc() wrapper; bails on failure

Definition at line 81 of file memory.c.

References no_alloc_fail().

Referenced by canonical_string_appendc(), canonical_string_appends(), canonical_string_init(), canonical_string_init_by_test(), ensure_buf(), fs_open_dir(), fs_read_dir(), ptr_vector_insert(), readon(), and vformat_output().

Here is the call graph for this function:

void release ( void **  pp)

Safely free a pointer.

Parameters:
ppAddress of the pointer to be freed

If *pp is NULL nothing is done. Otherwise *pp is freed and set = NULL.

Definition at line 92 of file memory.c.

Referenced by component_finitor(), eval_numeral(), forget_pending_contradiction(), vformat_output(), and vreport().

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines