M4RI  20140914
Data Structures | Macros | Typedefs | Functions
mmc.h File Reference

The mmc memory management functions check a cache for re-usable unused memory before asking the system for it. More...

#include <m4ri/misc.h>

Go to the source code of this file.

Data Structures

struct  _mm_block
 Tuple of pointer to allocated memory block and it's size. More...
 

Macros

#define __M4RI_MMC_NBLOCKS   16
 Number of blocks that are cached.
 
#define __M4RI_MMC_THRESHOLD   __M4RI_CPU_L3_CACHE
 Maximal size of blocks stored in cache.
 

Typedefs

typedef struct _mm_block mmb_t
 Tuple of pointer to allocated memory block and it's size.
 

Functions

void * m4ri_mmc_malloc (size_t size)
 Allocate size bytes. More...
 
void m4ri_mmc_free (void *condemned, size_t size)
 Free the data pointed to by condemned of the given size. More...
 
void m4ri_mmc_cleanup (void)
 Cleans up memory block cache. More...
 
static void * m4ri_mmc_calloc (size_t count, size_t size)
 Allocate an array of count times size zeroed bytes. More...
 

Detailed Description

The mmc memory management functions check a cache for re-usable unused memory before asking the system for it.

Author
Gregory Bard bard@.nosp@m.ford.nosp@m.ham.e.nosp@m.du
Martin Albrecht M.R.A.nosp@m.lbre.nosp@m.cht@r.nosp@m.hul..nosp@m.ac.uk

Function Documentation

static void* m4ri_mmc_calloc ( size_t  count,
size_t  size 
)
inlinestatic

Allocate an array of count times size zeroed bytes.

Parameters
countNumber of elements.
sizeNumber of bytes per element.
Returns
Pointer to allocated memory block.
void m4ri_mmc_cleanup ( void  )

Cleans up memory block cache.

This function is called automatically when the shared library is unloaded.

Warning
Not thread safe.
void m4ri_mmc_free ( void *  condemned,
size_t  size 
)

Free the data pointed to by condemned of the given size.

Parameters
condemnedPointer to memory.
sizeNumber of bytes.
void* m4ri_mmc_malloc ( size_t  size)

Allocate size bytes.

Parameters
sizeNumber of bytes.
Returns
pointer to allocated memory block.