Provide API to pool `CSteamNetworkingMessage`
It seems that CSteamNetworkingMessage doesn't pool messages.
This means that for each call to ISteamNetworkingUtils::AllocateMessage(), it dynamically allocates 264 bytes structure (on 64-bit environments).
This could be slow if you need to send loads of messages frequently.
I tried providing my own version of AllocateMessage() that allocates a message from my own pool, and initialize the CSteamNetworkingMessage properly.
But I realized you can't do that, because there's no way to initialize CSteamNetworkingMessage's private fields: m_links & m_linksSecondaryQueue
(Well, technically, I can just memset(msg, 0, 264) to initialize the hidden fields...
But not only that's UB, I can't tell if Steamworks SDK version of the message uses the same CSteamNetworkingMessage under the hood.)
It would be nice if there's an way to pool the message structure itself with the exposed m_pfnRelease,
like you can with m_pfnFreeData for the payloads.
Also, it would be great if you can also pool the message structure for the received messages too.
Looks like the Steamworks SDK version uses the same CSteamNetworkingMessage internally.
(Not 100% sure, but at least in the steam_api64.dll, there's the assembly code to initialize the m_links & m_linksSecondaryQueue.)
This is pretty hacky, but I can just copy-paste the CSteamNetworkingMessage declaration to my library for now.
Use SetCustomMemoryAllocator
Use SetCustomMemoryAllocator
That would set a global allocator for GNS, not specific to the CSteamNetworkingMessage pooling.
Also, that function is only available on the standalone GNS; It is not available on the Steamworks SDK.