Aegis  4.25.D505
Defines | Functions
Memory

Memory management functions. More...

Defines

#define THROW_BAD_ALLOC

Functions

void * mem_alloc (size_t nbytes)
 allocate memory
void * mem_alloc_clear (size_t nbytes)
 allocate and clear memory
void * mem_change_size (void *, size_t)
void mem_free (void *)
char * mem_copy_string (const char *arg)
char * mem_copy_string (const char *arg, size_t len)
void * operator new (size_t nbytes) THROW_BAD_ALLOC
void * operator new[] (size_t nbytes) THROW_BAD_ALLOC
void operator delete (void *ptr) throw ()
void operator delete[] (void *ptr) throw ()

Detailed Description

Memory management functions.


Define Documentation

#define THROW_BAD_ALLOC

Definition at line 128 of file mem.h.


Function Documentation

void* mem_alloc ( size_t  nbytes)

allocate memory

mem_alloc uses malloc to allocate the required sized chunk of memory. If any error is returned from malloc() a fatal diagnostic is issued.

Parameters:
nbytesThe size of the memory to allocate.
Warning:
It is the responsibility of the caller to ensure that the space is freed when finished with, by a call to mem_free().
void* mem_alloc_clear ( size_t  nbytes)

allocate and clear memory

mem_alloc_clear uses malloc to allocate the required sized chunk of memory. If any error is returned from malloc() an fatal diagnostic is issued. The memory is zeroed befor it is returned.

Parameters:
nbytesThe size of the memory to allocate
Warning:
It is the responsibility of the caller to ensure that the space is freed when finished with, by a call to free().
void* mem_change_size ( void *  ,
size_t   
)
char* mem_copy_string ( const char *  arg)

The mem_copy_string function may be used to copy a C string into dynamically allocated memory.

Parameters:
argThe NUL terminated string to be copied.
Returns:
A copy of the string in dynamic memory. Use mem_free when you are done with it.
char* mem_copy_string ( const char *  arg,
size_t  len 
)

The mem_copy_string function may be used to copy a string into dynamically allocated memory.

Parameters:
argThe string to be copied (it is *not* NUL terminated).
lenThe length of the string to be copied.
Returns:
A copy of the string in dynamic memory. The copy *is* NUL terminated. Use mem_free when you are done with it.
void mem_free ( void *  )
void operator delete ( void *  ptr) throw ()
void operator delete[] ( void *  ptr) throw ()
void* operator new ( size_t  nbytes)
void* operator new[] ( size_t  nbytes)