memory.c File Reference

Memory module implementation file. More...

#include "memory.h"
#include "definitions.h"
#include "log_util.h"
Include dependency graph for memory.c:

Go to the source code of this file.

Functions

void * memory_allocate (mcl_size_t bytes, const char *function, unsigned line)
 
void * memory_allocate_with_zero (mcl_size_t count, mcl_size_t bytes, const char *function, unsigned line)
 
void * memory_reallocate (void *p, mcl_size_t bytes, const char *function, unsigned line)
 
void memory_release (void *p, const char *function, unsigned line)
 
void * memory_malloc (mcl_size_t size)
 malloc wrapper More...
 
void * memory_calloc (mcl_size_t count, mcl_size_t bytes)
 calloc wrapper More...
 
void * memory_realloc (void *p, mcl_size_t bytes)
 realloc wrapper More...
 
void memory_free (void *p)
 free wrapper More...
 

Detailed Description

Memory module implementation file.


Date
Jul 28, 2016

Definition in file memory.c.

Function Documentation

void* memory_allocate ( mcl_size_t  bytes,
const char *  function,
unsigned  line 
)

This function is called to allocate memory.

See also
memory_malloc() for more details.
Parameters
bytesSize of the space to be allocated.
functionThe name of the calling function. Gathered with FUNCTION macro.
lineThe line of the calling function. Gathered with LINE macro.
Returns
Pointer to the allocated memory space.

Definition at line 22 of file memory.c.

References ASSERT_MESSAGE, MCL_NULL, MCL_VERBOSE, memory_malloc(), VERBOSE_ENTRY, and VERBOSE_LEAVE.

Here is the call graph for this function:

void* memory_allocate_with_zero ( mcl_size_t  count,
mcl_size_t  bytes,
const char *  function,
unsigned  line 
)

This function is called to allocate memory and initialize it with zero.

See also
memory_calloc() for more details.
Parameters
countCount of the object to be created. Total memory space will be (count*bytes)
bytesSize of the space to be allocated.
functionThe name of the calling function. Gathered with FUNCTION macro.
lineThe line of the calling function. Gathered with LINE macro.
Returns
Pointer to the allocated memory space.

Definition at line 39 of file memory.c.

References ASSERT_MESSAGE, MCL_VERBOSE, memory_calloc(), VERBOSE_ENTRY, and VERBOSE_LEAVE.

Here is the call graph for this function:

void* memory_calloc ( mcl_size_t  count,
mcl_size_t  bytes 
)

calloc wrapper

If stddef.h is exists in the system it uses the calloc function. If another implementation will be needed it can be added.

Parameters
countCount of the object to be created. Total memory space will be (count*bytes)
bytesSize of the space to be allocated.
Returns
Pointer to the allocated memory space.

Definition at line 109 of file memory.c.

References VERBOSE_ENTRY, and VERBOSE_LEAVE.

Referenced by http_client_initialize(), and memory_allocate_with_zero().

Here is the caller graph for this function:

void memory_free ( void *  p)

free wrapper

If stddef.h is exists in the system it uses the free function. If another implementation will be needed it can be added.

Parameters
pThe pointer to be freed.

Definition at line 129 of file memory.c.

References MCL_VERBOSE, VERBOSE_ENTRY, and VERBOSE_LEAVE.

Referenced by _libcrypto_free(), http_client_initialize(), json_util_initialize_json_library(), and memory_release().

Here is the caller graph for this function:

void* memory_malloc ( mcl_size_t  size)

malloc wrapper

If stddef.h is exists it uses the malloc function. If another implementation will be needed it can be added.

Parameters
sizeSize of the space to be allocated.
Returns
Pointer to the allocated memory space.

Definition at line 99 of file memory.c.

References VERBOSE_ENTRY, and VERBOSE_LEAVE.

Referenced by _libcrypto_malloc(), http_client_initialize(), json_util_initialize_json_library(), and memory_allocate().

Here is the caller graph for this function:

void* memory_realloc ( void *  p,
mcl_size_t  bytes 
)

realloc wrapper

If stddef.h is exists in the system it uses the realloc function. If another implementation will be needed it can be added.

Parameters
pThe pointer to be reallocated.
bytesSize of the space to be allocated.
Returns
Pointer to the reallocated memory space.

Definition at line 119 of file memory.c.

References VERBOSE_ENTRY, and VERBOSE_LEAVE.

Referenced by _libcrypto_realloc(), http_client_initialize(), and memory_reallocate().

Here is the caller graph for this function:

void* memory_reallocate ( void *  p,
mcl_size_t  bytes,
const char *  function,
unsigned  line 
)

This function is called to reallocate memory.

See also
memory_realloc() for more details.
Parameters
pThe pointer to be reallocated.
bytesSize of the space to be allocated.
functionThe name of the calling function. Gathered with FUNCTION macro.
lineThe line of the calling function. Gathered with LINE macro.
Returns
Pointer to the reallocated memory space.

Definition at line 57 of file memory.c.

References ASSERT_MESSAGE, MCL_FREE, MCL_NULL, MCL_VERBOSE, memory_realloc(), VERBOSE_ENTRY, and VERBOSE_LEAVE.

Here is the call graph for this function:

void memory_release ( void *  p,
const char *  function,
unsigned  line 
)

This function is called to free memory.

See also
memory_free() for more details.
Parameters
pThe pointer to be freed.
functionThe name of the calling function. Gathered with FUNCTION macro.
lineThe line of the calling function. Gathered with LINE macro.

Definition at line 83 of file memory.c.

References MCL_NULL, MCL_VERBOSE, memory_free(), VERBOSE_ENTRY, and VERBOSE_LEAVE.

Here is the call graph for this function: