The Memory Allocation Utility

This document is part of the online Horus Documentation, under Horus Utilities.


--MUTS uses this internal interface to allocate memory. It should not normally be invoked by applications (instead, they use memory channels). Different from the standard C malloc() interface, the --MUTS interfaces are thread-safe. In addition, the --MUTS implementation typically provides debugging features, and optimization by caching blocks of common sizes.

SOURCES

machdep/*/mem_alloc.c

INCLUDE

#include "muts.h"

SWITCHES

#define MEM_DEBUG	/* turn on debugging */
#define MEM_PURIFY	/* turn off optimization */
#define NO_REALLOC	/* don't use realloc() */

INTERFACE

void mem_init(void);
Initialization of this module.
void *mem_alloc(int size);
Allocate size bytes of memory. The memory is not initialized in any way. Returns zero on error.
void *mem_realloc(void *mem, int size);
Change the size of the memory. The location of the memory may change, and is returned.
void mem_free(void *mem);
Free memory allocated by mem_alloc or mem_realloc.
int mem_size(void *mem);
Returns the size of a block of allocated memory.
void mem_dump(struct bio *output);
Print the memory allocation statistics:
    alloc:	# bytes allocated by mem_alloc
    free:	# bytes freed by mem_free
    realloc:	# bytes allocated by mem_realloc
    refree:	# bytes freed by mem_realloc
    nalloc:	# calls of mem_alloc
    nfree:	# calls of mem_free
    nrealloc:	# calls of mem_realloc
float mem_rate(void);
Returns how many bytes / second can be ideally allocated.

EXAMPLE

not available yet


This document is part of the online Horus Documentation, under Horus Utilities.