void __RPC_FAR * __RPC_USER midl_user_allocate (size_t cBytes);
Both client applications and server applications must implement the midl_user_allocate function, unless you are compiling in OSF-compatibility (/osf) mode. Applications and generated stubs call midl_user_allocate directly or indirectly to manage allocated objects. For example:
If midl_user_allocate fails to allocate memory, it should return a null pointer or raise a user-defined exception.
The midl_user_allocate function should return a pointer as shown:
For example, the sample programs provided with the Win32 SDK implement midl_user_allocate in terms of the C function malloc:
void __RPC_FAR * __RPC_USER midl_user_allocate(size_t cBytes)
{
return((void __RPC_FAR *) malloc(cBytes));
}
Note If the Rpcss package is enabled (for example, as the result of using the enable_allocate attribute), RpcSmAllocate should be used to allocate memory on the server side. For additional information on enable_allocate, see MIDL Reference.