Final Platform Layer  0.9.6-beta
Data Structures | Typedefs | Functions
Memory functions

This category contains functions for allocating/manipulating memory. More...

Data Structures

struct  fplMemoryBlock
 Defines a memory block. More...
 
struct  fplMemoryInfos
 A structure that contains informations about current memory usage. More...
 

Typedefs

typedef struct fplMemoryBlock fplMemoryBlock
 Defines a memory block.
 
typedef struct fplMemoryInfos fplMemoryInfos
 A structure that contains informations about current memory usage.
 

Functions

fpl_common_api void * fplMemoryAlignedAllocate (const size_t size, const size_t alignment)
 Allocates aligned memory from the operating system by the given alignment. More...
 
fpl_common_api void fplMemoryAlignedFree (void *ptr)
 Releases the aligned memory allocated from the operating system. More...
 
fpl_platform_api void * fplMemoryAllocate (const size_t size)
 Allocates memory from the operating system by the given size. More...
 
fpl_common_api void fplMemoryClear (void *mem, const size_t size)
 Clears the given memory by the given size to zero. More...
 
fpl_common_api void fplMemoryCopy (const void *sourceMem, const size_t sourceSize, void *targetMem)
 Copies the given source memory with its length to the target memory. More...
 
fpl_platform_api void fplMemoryFree (void *ptr)
 Releases the memory allocated from the operating system. More...
 
fpl_platform_api bool fplMemoryGetInfos (fplMemoryInfos *outInfos)
 Retrieves the current system memory usage. More...
 
fpl_common_api void fplMemorySet (void *mem, const uint8_t value, const size_t size)
 Sets the given memory by the given size to the given value. More...
 

Detailed Description

This category contains functions for allocating/manipulating memory.

Function Documentation

◆ fplMemoryAlignedAllocate()

fpl_common_api void* fplMemoryAlignedAllocate ( const size_t  size,
const size_t  alignment 
)

Allocates aligned memory from the operating system by the given alignment.

Parameters
sizeThe size amount in bytes
alignmentThe alignment in bytes (Must be a power-of-two!)
Returns
Returns the pointer to the new allocated aligned memory.
Note
The memory is guaranteed to be initialized to zero.
This function can be called without the platform to be initialized.
See also
Allocate custom aligned (n)-bytes of memory

◆ fplMemoryAlignedFree()

fpl_common_api void fplMemoryAlignedFree ( void *  ptr)

Releases the aligned memory allocated from the operating system.

Parameters
ptrThe pointer to the aligned allocated memory
Warning
This should never be called with a not-aligned memory pointer! For freeing not-aligned memory, use fplMemoryFree() instead.
Note
This function can be called without the platform to be initialized.
See also
Free aligned memory

◆ fplMemoryAllocate()

fpl_platform_api void* fplMemoryAllocate ( const size_t  size)

Allocates memory from the operating system by the given size.

Parameters
sizeThe size to be allocated in bytes.
Returns
Returns a pointer to the newly allocated memory.
Warning
Alignment is not ensured here, the OS decides how to handle this. If you want to force a specific alignment use fplMemoryAlignedAllocate() instead.
Note
The memory is guaranteed to be initialized to zero.
This function can be called without the platform to be initialized.
See also
Allocate (n)-bytes of memory

◆ fplMemoryClear()

fpl_common_api void fplMemoryClear ( void *  mem,
const size_t  size 
)

Clears the given memory by the given size to zero.

Parameters
memThe pointer to the memory
sizeThe number of bytes to be cleared to zero
See also
Clear (n)-bytes of memory

◆ fplMemoryCopy()

fpl_common_api void fplMemoryCopy ( const void *  sourceMem,
const size_t  sourceSize,
void *  targetMem 
)

Copies the given source memory with its length to the target memory.

Parameters
sourceMemThe pointer to the source memory to copy from
sourceSizeThe size in bytes to be copied
targetMemThe pointer to the target memory to copy into
See also
Copy (n)-bytes of memory to another memory location

◆ fplMemoryFree()

fpl_platform_api void fplMemoryFree ( void *  ptr)

Releases the memory allocated from the operating system.

Parameters
ptrThe pointer to the allocated memory
Warning
This should never be called with an aligned memory pointer! For freeing aligned memory, use fplMemoryAlignedFree() instead.
Note
This function can be called without the platform to be initialized.
See also
Free memory

◆ fplMemoryGetInfos()

fpl_platform_api bool fplMemoryGetInfos ( fplMemoryInfos outInfos)

Retrieves the current system memory usage.

Parameters
outInfosThe target fplMemoryInfos structure
Returns
Returns true when the memory infos was retrieved, false otherwise.
See also
Query memory state

◆ fplMemorySet()

fpl_common_api void fplMemorySet ( void *  mem,
const uint8_t  value,
const size_t  size 
)

Sets the given memory by the given size to the given value.

Parameters
memThe pointer to the memory
valueThe value to be set
sizeThe number of bytes to be set
See also
Overwrite (n)-bytes of memory with a given value