libmsr  0.3.0
A friendlier interface to accessing MSRs on Intel platforms
 All Classes Files Functions Variables Enumerations Enumerator Macros Pages
Functions
memhdlr.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "memhdlr.h"
#include "libmsr_error.h"
#include "libmsr_debug.h"
Include dependency graph for memhdlr.c:

Functions

void * libmsr_malloc (size_t size)
 Allocate size bytes with malloc().
 
void * libmsr_calloc (size_t num, size_t size)
 Allocate memory for an array of num elements of size bytes each with calloc().
 
void * libmsr_realloc (void *addr, size_t size)
 Change allocation of existing memory to size bytes with realloc().
 
void * libmsr_free (void *addr)
 Free single dynamic memory allocation.
 
void * memhdlr_finalize (void)
 Deallocate any remaining memory allocations and deallocate tracking structure.
 
int memory_handler (void *address, void *oldaddr, int type)
 Track all dynamic arrays allocated in libmsr to make deallocation simple.
 

Function Documentation

void* libmsr_calloc ( size_t  num,
size_t  size 
)

Allocate memory for an array of num elements of size bytes each with calloc().

Parameters
[in]sizeNumber of bytes.
[in]numNumber of elements.
Returns
Pointer to dynamic array.
void* libmsr_free ( void *  addr)

Free single dynamic memory allocation.

Parameters
[in]addrPointer to dynamic array.
Returns
Null pointer.
void* libmsr_malloc ( size_t  size)

Allocate size bytes with malloc().

Parameters
[in]sizeNumber of bytes.
Returns
Pointer to dynamic array.
void* libmsr_realloc ( void *  addr,
size_t  size 
)

Change allocation of existing memory to size bytes with realloc().

Parameters
[out]addrPointer to dynamic array.
[in]sizeNumber of bytes.
Returns
Pointer to dynamic array.
void* memhdlr_finalize ( void  )

Deallocate any remaining memory allocations and deallocate tracking structure.

Returns
Null pointer.
int memory_handler ( void *  address,
void *  oldaddr,
int  type 
)

Track all dynamic arrays allocated in libmsr to make deallocation simple.

Parameters
[out]addressPointer to dynamic array.
[out]oldaddrPointer to dynamic array.
[in]typelibmsr_mem_mgmt_e memory management identifier.
Returns
0 if successful, -1 if malloc() or realloc() fails.