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.
machdep/*/mem_alloc.c
#include "muts.h"
#define MEM_DEBUG /* turn on debugging */ #define MEM_PURIFY /* turn off optimization */ #define NO_REALLOC /* don't use realloc() */
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.
not available yet