How Memory Is Allocated and Deallocated

By default, stub code generated by the MIDL compiler calls user-supplied functions to allocate and free memory. These functions, named midl_user_allocate and midl_user_free, must be supplied by the developer and linked with the application.

All applications must supply implementations of midl_user_allocate and midl_user_free, even though the names of these functions may not appear explicitly in the stubs. The only exception is when you are compiling in OSF-compatibility (/osf) mode. These user-supplied functions must match a specific, defined function prototype but otherwise, can be implemented in any way that is convenient or useful for the application. Alternatively, applications can use the RpcSs Memory Management Package. The Microsoft RPC run-time library supplies this group of functions.

The following sections describe the RPC memory management functions.