The midl_user_free Function
The midl_user_free function must be supplied by RPC developers. It frees memory allocated by midl_user_allocate for the RPC stubs and library routines. Your midl_user_free function must match the following prototype:
void __RPC_USER midl_user_free(void * pBuffer);
The pBuffer parameter specifies a pointer to the memory that is to be freed. Both client application and server application must implement the midl_user_free function unless you are compiling in OSF-compatibility (/osf) mode. The midl_user_free function must be able to free all storage allocated by midl_user_allocate.
Applications and stubs call midl_user_free when dealing with allocated objects:
- The server application should call midl_user_free to free memory allocated by the application, such as when deleting a dynamically allocated node of data.
- The server stub calls midl_user_free to release memory on the server after marshaling all [out] arguments, [in],[out] arguments, and the function return value.
For example, the RPC Windows sample program that displays "Hello, world" implements midl_user_free in terms of the C function free:
void __RPC_USER midl_user_free(void __RPC_FAR * p)
{
free(p);
}
Note
If the RpcSs package is enabled (for example, as the result of using the [ enable_allocate] attribute), your server program should use RpcSmFree to free memory. For more information, see RpcSs Memory Management Package.