memory.h File Reference

Memory module header file. More...

#include "mcl/mcl_common.h"
Include dependency graph for memory.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MCL_MALLOC(bytes)   memory_allocate(bytes, __FUNCTION__, __LINE__)
 
#define MCL_NEW(p)   ((p) = MCL_MALLOC((long)sizeof (*p)))
 
#define MCL_CALLOC(count, bytes)   memory_allocate_with_zero(count, bytes, __FUNCTION__, __LINE__)
 
#define MCL_NEW_WITH_ZERO(p)   ((p) = MCL_CALLOC(1, (long)sizeof *(p)))
 
#define MCL_RESIZE(p, bytes)   ((p) = memory_reallocate(p, bytes, __FUNCTION__, __LINE__))
 
#define MCL_FREE(p)   ((void)(memory_release((p), __FUNCTION__, (mcl_uint32_t)__LINE__), (p) = MCL_NULL))
 

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 header file.


Date
Jul 28, 2016 This module contains functions and macro definitions for memory allocation/deallocation operations.

Definition in file memory.h.

Macro Definition Documentation

#define MCL_CALLOC (   count,
  bytes 
)    memory_allocate_with_zero(count, bytes, __FUNCTION__, __LINE__)
#define MCL_FREE (   p)    ((void)(memory_release((p), __FUNCTION__, (mcl_uint32_t)__LINE__), (p) = MCL_NULL))

Definition at line 125 of file memory.h.

Referenced by _base64_encode_big_number(), _calculate_signature(), _compose_rsa_key_rotation_json(), _compose_rsa_onboarding_json(), _decode_with_table(), _destroy_data_point(), _destroy_data_source(), _destroy_value_set(), _destroy_value_set_value(), _exchange_prepare_data(), _finish_json_item(), _get_rsa_private_key(), _get_rsa_public_key(), _process_registration_response_rsa_3072(), _process_registration_response_shared_secret(), _store_add_data(), _store_list_destroy_callback(), custom_data_destroy(), data_source_configuration_destroy(), event_destroy(), event_initialize(), event_list_destroy(), event_list_initialize(), file_destroy(), hmac_sha256(), http_client_destroy(), http_client_send(), http_processor_destroy(), http_processor_get_access_token(), http_processor_update_security_information(), http_request_destroy(), http_response_destroy(), json_util_add_bool(), json_util_add_double(), json_util_add_null(), json_util_add_object(), json_util_add_string(), json_util_add_uint(), json_util_destroy(), json_util_duplicate(), json_util_get_array_item(), json_util_get_object_item(), json_util_initialize(), json_util_parse(), json_util_parse_with_size(), json_util_start_array(), json_util_start_object(), jwt_destroy(), list_destroy_with_content(), list_remove(), mcl_communication_destroy(), mcl_communication_get_last_access_token(), mcl_communication_get_last_token_time(), mcl_configuration_destroy(), mcl_data_source_configuration_get_id(), mcl_json_util_get_string(), mcl_random_generate_guid(), mcl_store_destroy(), memory_reallocate(), random_generate_array(), random_generate_guid(), security_generate_rsa_key(), security_handler_destroy(), security_rsa_get_modulus_and_exponent(), security_rsa_sign(), storage_load_rsa_registration_information(), storage_load_shared_secret_registration_information(), stream_data_destroy(), string_array_destroy(), string_array_initialize(), string_array_to_string(), string_destroy(), string_initialize(), string_initialize_dynamic(), string_initialize_new(), string_initialize_static(), string_release(), string_replace(), time_series_destroy(), and time_util_convert_to_iso_8601_format().

#define MCL_NEW_WITH_ZERO (   p)    ((p) = MCL_CALLOC(1, (long)sizeof *(p)))

Definition at line 123 of file memory.h.

#define MCL_RESIZE (   p,
  bytes 
)    ((p) = memory_reallocate(p, bytes, __FUNCTION__, __LINE__))

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: