Skip to main content
A callback that PlayFab calls every time it needs to dynamically allocate a memory buffer.

Syntax

Parameters

size   _In_ size_t The size, in bytes, of the allocation to make. This value is never zero. memoryTypeId   _In_ uint32_t An opaque identifier for the internal category of memory being allocated. Ignore this value.

Return value

Type: void* A pointer to an allocated block of memory of the specified size, or nullptr if the allocation failed. The header annotates the return value with _Ret_maybenull_ and _Post_writable_byte_size_(size).

Remarks

To install this callback, set it in the alloc member of a PFMemoryHooks structure and pass the structure to PFMemSetFunctions before you call PFInitialize. Set the free member to a matching PFMemFreeFunction callback at the same time. PFMemSetFunctions returns E_INVALIDARG if only one of the two members is set. The callback must return a pointer to a contiguous block of memory of the requested size. The block must stay valid until PlayFab passes it to your PFMemFreeFunction callback. PlayFab passes every non-null pointer that this callback returns to your PFMemFreeFunction callback when it no longer needs the memory. If libHttpClient isn’t initialized yet when you call PFMemSetFunctions, PlayFab also installs hooks that route libHttpClient’s allocations through this callback. To get the hooks that are currently in use, including the default hooks, call PFMemGetFunctions. PlayFab can call this callback from different threads, so make it thread-safe.

Requirements

Header: PFPlatform.h Library: PlayFabCore.lib Supported platforms: Windows, XBOX One family consoles, and XBOX Series consoles

See also

PFPlatform members PFMemoryHooks PFMemFreeFunction
Last modified on November 3, 2026