Functions | Variables
memory.c File Reference

This file contains various allocation routines. More...

#include <GKlib.h>
Include dependency graph for memory.c:

Go to the source code of this file.

Functions

void gk_AllocMatrix (void ***r_matrix, size_t elmlen, size_t ndim1, size_t ndim2)
 
void gk_free (void **ptr1,...)
 
void gk_FreeMatrix (void ***r_matrix, size_t ndim1, size_t ndim2)
 
size_t gk_GetCurMemoryUsed ()
 
size_t gk_GetMaxMemoryUsed ()
 
void * gk_malloc (size_t nbytes, char *msg)
 
void gk_malloc_cleanup (int showstats)
 
int gk_malloc_init ()
 
void * gk_realloc (void *oldptr, size_t nbytes, char *msg)
 

Variables

static __thread gk_mcore_tgkmcore = NULL
 

Detailed Description

This file contains various allocation routines.

The allocation routines included are for 1D and 2D arrays of the most datatypes that GKlib support. Many of these routines are defined with the help of the macros in gk_memory.h. These macros can be used to define other memory allocation routines.

Date
Started 4/3/2007
Author
George
Version
$Id: memory.c 10783 2011-09-21 23:19:56Z karypis $ 

Definition in file memory.c.

Function Documentation

◆ gk_AllocMatrix()

void gk_AllocMatrix ( void ***  r_matrix,
size_t  elmlen,
size_t  ndim1,
size_t  ndim2 
)

Define the set of memory allocation routines for each data type

This function allocates a two-dimensional matrix.

Definition at line 53 of file memory.c.

◆ gk_free()

void gk_free ( void **  ptr1,
  ... 
)

Definition at line 202 of file memory.c.

◆ gk_FreeMatrix()

void gk_FreeMatrix ( void ***  r_matrix,
size_t  ndim1,
size_t  ndim2 
)

This function frees a two-dimensional matrix.

Definition at line 79 of file memory.c.

◆ gk_GetCurMemoryUsed()

size_t gk_GetCurMemoryUsed ( )

Definition at line 233 of file memory.c.

◆ gk_GetMaxMemoryUsed()

size_t gk_GetMaxMemoryUsed ( )

Definition at line 246 of file memory.c.

◆ gk_malloc()

void* gk_malloc ( size_t  nbytes,
char *  msg 
)

This function is my wrapper around malloc that provides the following enhancements over malloc: It always allocates one byte of memory, even if 0 bytes are requested. This is to ensure that checks of returned values do not lead to NULL due to 0 bytes requested. It zeros-out the memory that is allocated. This is for a quick init of the underlying datastructures.

Definition at line 140 of file memory.c.

◆ gk_malloc_cleanup()

void gk_malloc_cleanup ( int  showstats)

This function frees the memory that has been allocated since the last call to gk_malloc_init().

Definition at line 118 of file memory.c.

◆ gk_malloc_init()

int gk_malloc_init ( )

This function initializes tracking of heap allocations.

Definition at line 99 of file memory.c.

◆ gk_realloc()

void* gk_realloc ( void *  oldptr,
size_t  nbytes,
char *  msg 
)

Definition at line 172 of file memory.c.

Variable Documentation

◆ gkmcore

__thread gk_mcore_t* gkmcore = NULL
static

Definition at line 19 of file memory.c.



gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:09:49