The "m" Package

These routines are meant to provide a better memory allocation service than the malloc(3) call. The supplied allocation and deallocation routines perform periodic checks to see if array boundaries have been overrun. A set of memory manipulation and error message routines are also provided in this package.

Library: karma
Link With: -lkarma

Functions

m_allocAllocate Virtual Memory.
m_freeFree Virtual Memory.
m_error_notifyPrint memory error notification message.
m_abortPrint memory error notification message and abort.
m_verify_memory_integrityPeriodically verify memory integrity.
m_clearClear a block of memory
m_copyCopy a block of memory.
m_copy_blocksCopy multiple blocks of data.
m_copy_and_swap_blocksCopy and byte-swap multiple blocks of data.
m_fillFill memory blocks with a specified value.
m_cmpCompare two blocks of memory.
m_dupDuplicate a block of memory into a freshly allocated block.
m_alloc_scratchAllocate a block of scratch memory.
m_free_scratchFree the scratch memory.


Functions


char * m_alloc (uaddr size)

Allocate Virtual Memory.

Parameters:

Returns: A pointer to the memory on success, else NULL.
Multithreading Level: Safe under Solaris 2.
Note:


void m_free (char *ptr)

Free Virtual Memory.

Parameters:

Returns: Nothing.
Multithreading Level: Safe.
Note:


void m_error_notify (char *function_name, char *purpose)

Print memory error notification message.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void m_abort (char *name, char *reason)

Print memory error notification message and abort.

Parameters:

Returns: Nothing. The process aborts.
Multithreading Level: Unsafe


unsigned int m_verify_memory_integrity (flag force)

Periodically verify memory integrity.

Parameters:

Returns: The number of corrupted blocks.
Multithreading Level: Safe.


void m_clear (char *memory, uaddr length)

Clear a block of memory

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe
Note:


void m_copy (char *dest, CONST char *source, uaddr length)

Copy a block of memory.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe
Note:


void m_copy_blocks (char *dest, CONST char *source, unsigned int dest_stride, unsigned int source_stride, unsigned int block_size, unsigned int num_blocks)

Copy multiple blocks of data.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void m_copy_and_swap_blocks (char *dest, CONST char *source, uaddr dest_stride, uaddr source_stride, uaddr block_size, uaddr num_blocks)

Copy and byte-swap multiple blocks of data.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void m_fill (char *dest, uaddr stride, CONST char *source, uaddr size, unsigned int num)

Fill memory blocks with a specified value.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


flag m_cmp (CONST char *block1, CONST char *block2, uaddr length)

Compare two blocks of memory.

Parameters:

Returns: TRUE if the blocks are equal, else FALSE.
Multithreading Level: Unsafe
Note:


char * m_dup (CONST char *original, uaddr size)

Duplicate a block of memory into a freshly allocated block.

Parameters:

Returns: A pointer to a freshly allocated block which contains identical data as the orginal on success, else NULL.
Multithreading Level: Unsafe


char * m_alloc_scratch (uaddr size, char *function_name)

This routine will allocate a block of scratch memory, which may be re-used by many different routines. The block is reserved until a call is made to m_free_scratch.

Parameters:

Returns: A pointer on success to a dynamically allocated block of memory which is valid until the next call to this routine, else NULL.
Multithreading Level: Unsafe


void m_free_scratch ()

Free the scratch memory.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


Contact: Richard Gooch
Web Development: Ariel Internet Services