Edit

PFMultiplayerAllocateMemoryCallback

A callback invoked every time a new memory buffer must be dynamically allocated by the PlayFab Multiplayer library.

Syntax

void* PFMULTIPLAYER_API PFMultiplayerAllocateMemoryCallback(  
    size_t size,  
    PFMultiplayerMemoryType memoryTypeId  
);  

Parameters

size   size_t

The size of the allocation to be made. This value will never be zero.

memoryTypeId   PFMultiplayerMemoryType

An opaque identifier representing the PlayFab Multiplayer library internal category of memory being allocated. Generally, you can ignore this value, but you can use it to help diagnose and debug Multiplayer memory allocations.

Return value

Type: void*

Ret_maybenull, Post_writable_byte_size(size)

A pointer to an allocated block of memory of the specified size, or nullptr if the allocation failed.

Remarks

This callback is optionally installed using the PFMultiplayerSetMemoryCallbacks() method.

The callback must allocate and return a pointer to a contiguous block of memory of the specified size that will remain valid until the title's corresponding PFMultiplayerFreeMemoryCallback is invoked to release it. If this is not possible, the callback must return nullptr to fail the allocation. Memory allocation failures are sometimes considered benign but will usually cause current PlayFab Multiplayer library operation(s) to fail.

Every non-nullptr returned by this method will be subsequently passed to the corresponding PFMultiplayerFreeMemoryCallback once the memory is no longer needed.

Requirements

Header: PFMultiplayer.h

See also

PFMultiplayer members
PFMultiplayerFreeMemoryCallback
PFMultiplayerSetMemoryCallbacks