RpcSsAllocate function (rpcndr.h)

The RpcSsAllocate function allocates memory within the RPC stub memory-management function, and returns a pointer to the allocated memory or NULL.


void * RpcSsAllocate(
  size_t Size



Size of memory to allocate, in bytes.

Return value

Value Meaning
The system is out of memory.
Note  For a list of valid error codes, see RPC Return Values.


The RpcSsAllocate function allows an application to allocate memory within the RPC stub memory–management function. Prior to calling RpcSsAllocate, the memory-management environment must already be established. For memory management called within the stub, the stub itself usually establishes the necessary environment. For more information, see Memory Management. When using RpcSsAllocate to allocate memory not called from the stub, the application must call RpcSsEnableAllocate to establish the required memory-management environment.

The RpcSsAllocate routine returns a pointer to the allocated memory, if the call was successful. Otherwise, it raises an exception.

When the stub establishes the memory management, it frees any memory allocated by RpcSsAllocate. The application can free such memory before returning to the calling stub by calling RpcSsFree.

By contrast, when the application establishes the memory management, it must free any allocated memory. It does so by calling either RpcSsFree or RpcSsDisableAllocate.

To manage the same memory within the stub memory–management environment, multiple threads can call RpcSsAllocate and RpcSsFree. In this case, the threads must share the same stub memory management–thread handle. Applications pass thread handles from thread-to-thread by calling RpcSsGetThreadHandle and RPCSsSetThreadHandle.

Note  The RpcSsAllocate routine raises exceptions, unlike RpcSmAllocate, which returns the error code.


Minimum supported client Windows 2000 Professional [desktop apps | UWP apps]
Minimum supported server Windows 2000 Server [desktop apps | UWP apps]
Target Platform Windows
Header rpcndr.h (include Rpc.h)
Library Rpcrt4.lib
DLL Rpcrt4.dll

See also