51Degrees Device Detection C/C++  4.1

A device detection library that is used natively or by 51Degrees products

Memory

Detailed Description

Utility methods used to handle common memory operations such as allocating memory and freeing it, or reading through continuous memory checking for buffer over or under runs.

Collaboration diagram for Memory:

Structs

struct  fiftyoneDegreesMemoryReader
Used to read data from memory in a similar manner to a file handle. More...

Functions

bool  fiftyoneDegreesMemoryAdvance (fiftyoneDegreesMemoryReader *reader, size_t advanceBy)
Used to read continuous memory checking for buffer over or under runs. More...
void *  fiftyoneDegreesMemoryStandardMalloc (size_t __size)
Allocates memory using the standard malloc method. More...
void *  fiftyoneDegreesMemoryTrackingMalloc (size_t __size)
Allocates memory while keeping track of the memory which has been allocated using this method since calling fiftyoneDegreesMemoryTrackingReset. More...
void *  fiftyoneDegreesMemoryStandardMallocAligned (int alignment, size_t __size)
Allocated aligned memory using the standard malloc method. More...
void *  fiftyoneDegreesMemoryTrackingMallocAligned (int alignment, size_t __size)
Allocates aligned memory while keeping track of the memory which has been allocated using this method since calling fiftyoneDegreesMemoryTrackingReset. More...
void  fiftyoneDegreesMemoryTrackingFree (void *__ptr)
Frees memory allocated using the fiftyoneDegreesMemoryTrackingMalloc method, noting that it has now been freed and does not contribute to the current total. More...
void  fiftyoneDegreesMemoryTrackingFreeAligned (void *__ptr)
Frees memory allocated using the fiftyoneDegreesMemoryTrackingMallocAligned method, noting that it has now been freed and does not contribute to the current total. More...
void  fiftyoneDegreesMemoryStandardFree (void *__ptr)
Frees memory using the standard free method. More...
void  fiftyoneDegreesMemoryStandardFreeAligned (void *__ptr)
Frees memory using the standard aligned free method. More...
size_t  fiftyoneDegreesMemoryTrackingGetMax ()
Gets the maximum total number of bytes that have been allocated using the fiftyoneDegreesMemoryTrackingMalloc method. More...
size_t  fiftyoneDegreesMemoryTrackingGetAllocated ()
Gets the current number of bytes allocated using the tracking malloc and free methods. More...
void  fiftyoneDegreesMemoryTrackingReset ()
Resets the memory trackers keeping track of the data allocated using the fiftyoneDegreesMemoryTrackingMalloc method. More...

Variables

void *(*  fiftyoneDegreesMalloc )(size_t __size)
Pointer to the method used to allocate memory. More...
void *(*  fiftyoneDegreesMallocAligned )(int alignment, size_t __size)
Pointer to the method used to allocate aligned memory. More...
void(*  fiftyoneDegreesFree )(void *__ptr)
Pointer to the method used to free memory. More...
void(*  fiftyoneDegreesFreeAligned )(void *__ptr)
Pointer to the method used to free memory. More...

Function Documentation

◆ fiftyoneDegreesMemoryAdvance()

bool fiftyoneDegreesMemoryAdvance ( fiftyoneDegreesMemoryReader *   reader,
size_t   advanceBy  
)

Used to read continuous memory checking for buffer over or under runs.

Parameters
reader - structure used to check for last byte
advanceBy - number of bytes to advance current by
Returns
true if the advance succeeded, otherwise false

◆ fiftyoneDegreesMemoryStandardFree()

void fiftyoneDegreesMemoryStandardFree ( void *   __ptr )

Frees memory using the standard free method.

Parameters
__ptr - data to free

◆ fiftyoneDegreesMemoryStandardFreeAligned()

void fiftyoneDegreesMemoryStandardFreeAligned ( void *   __ptr )

Frees memory using the standard aligned free method.

Parameters
__ptr - data to free

◆ fiftyoneDegreesMemoryStandardMalloc()

void* fiftyoneDegreesMemoryStandardMalloc ( size_t   __size )

Allocates memory using the standard malloc method.

Parameters
__size - number of bytes to allocate
Returns
pointer to allocated memory or NULL

◆ fiftyoneDegreesMemoryStandardMallocAligned()

void* fiftyoneDegreesMemoryStandardMallocAligned ( int   alignment,
size_t   __size  
)

Allocated aligned memory using the standard malloc method.

Parameters
alignment - byte boundary to align the allocation to e.g. 16
__size - number of bytes to allocate
Returns
pointer to allocation memory or NULL

◆ fiftyoneDegreesMemoryTrackingFree()

void fiftyoneDegreesMemoryTrackingFree ( void *   __ptr )

Frees memory allocated using the fiftyoneDegreesMemoryTrackingMalloc method, noting that it has now been freed and does not contribute to the current total.

Parameters
__ptr - data to free

◆ fiftyoneDegreesMemoryTrackingFreeAligned()

void fiftyoneDegreesMemoryTrackingFreeAligned ( void *   __ptr )

Frees memory allocated using the fiftyoneDegreesMemoryTrackingMallocAligned method, noting that it has now been freed and does not contribute to the current total.

Parameters
__ptr - data to free

◆ fiftyoneDegreesMemoryTrackingGetAllocated()

size_t fiftyoneDegreesMemoryTrackingGetAllocated ( )

Gets the current number of bytes allocated using the tracking malloc and free methods.

Returns
total bytes currently allocated

◆ fiftyoneDegreesMemoryTrackingGetMax()

size_t fiftyoneDegreesMemoryTrackingGetMax ( )

Gets the maximum total number of bytes that have been allocated using the fiftyoneDegreesMemoryTrackingMalloc method.

NOTE: this is the total at any point in time since the fiftyoneDegreesMemoryTrackingReset method was called, NOT the total allocated in a single allocation.

Returns
maximum total allocation

◆ fiftyoneDegreesMemoryTrackingMalloc()

void* fiftyoneDegreesMemoryTrackingMalloc ( size_t   __size )

Allocates memory while keeping track of the memory which has been allocated using this method since calling fiftyoneDegreesMemoryTrackingReset.

Parameters
__size - number of bytes to allocate
Returns
pointer to allocated memory or NULL

◆ fiftyoneDegreesMemoryTrackingMallocAligned()

void* fiftyoneDegreesMemoryTrackingMallocAligned ( int   alignment,
size_t   __size  
)

Allocates aligned memory while keeping track of the memory which has been allocated using this method since calling fiftyoneDegreesMemoryTrackingReset.

Parameters
alignment - byte boundary to align the allocation to e.g. 16
__size - number of bytes to allocate
Returns
pointer to allocation memory or NULL

◆ fiftyoneDegreesMemoryTrackingReset()

void fiftyoneDegreesMemoryTrackingReset ( )

Resets the memory trackers keeping track of the data allocated using the fiftyoneDegreesMemoryTrackingMalloc method.

This should always be called before tracking memory allocations.

Variable Documentation

◆ fiftyoneDegreesFreeAligned

void( * fiftyoneDegreesFreeAligned) (void *__ptr)

Pointer to the method used to free memory.

By default this maps to fiftyoneDegreesMemoryStandardFreeAligned which calls the standard library free.

Parameters
__ptr - pointer to free

◆ fiftyoneDegreesMalloc

void*( * fiftyoneDegreesMalloc) (size_t __size)

Pointer to the method used to allocate memory.

By default this maps to fiftyoneDegreesMemoryStandardMalloc which calls the standard library malloc.

Parameters
__size - to allocate
Returns
pointer to allocated memory or NULL

◆ fiftyoneDegreesMallocAligned

void*( * fiftyoneDegreesMallocAligned) (int alignment, size_t __size)

Pointer to the method used to allocate aligned memory.

By default this maps to fiftyoneDegreesMemoryStandardMallocAligned which calls the standard library malloc, allocating slightly more that requested, then ensures the pointer is aligned to a boundary.

Parameters
alignment - byte boundary to align the allocation to e.g. 16
__size - to allocate
Returns
pointer to allocated memory or NULL