大网数据广告活动
网络与域名解析

RpcSs Memory Management Package

· 52CE 我爱测

The default allocator/deallocator pair used by the stubs and run time when allocating memory on behalf of the application is midl_user_allocate/midl_user_free.

The default allocator/deallocator pair used by the stubs and run time when allocating memory on behalf of the application is midl_user_allocate/midl_user_free. However, you can choose the RpcSs package instead of the default by using the ACF attribute [enable_allocate]. The RpcSs package consists of RPC functions that begin with the prefix RpcSs or RpcSm. The RpcSs package is not recommended for Windows applications.

Note:
The Rpcss Memory Management Package is obsolete. It is recommended that midl_user_allocate and midl_user_free are used in its place.

In /osf mode, the RpcSs package is enabled for MIDL-generated stubs automatically when full pointers are used, when the arguments require memory allocation, or as a result of using the [enable_allocate] attribute. In the default (Microsoft extended) mode, the RpcSs package is enabled only when the [enable_allocate] attribute is used. The [enable_allocate] attribute enables the RpcSs environment by the server-side stubs. The client side becomes alerted to the possibility that the RpcSs package may be enabled. In /osf mode, the client side is not affected.

When the RpcSs package is enabled, allocation of memory on the server side is accomplished with the private RpcSs memory management allocator and deallocator pair. You can allocate memory using the same mechanism by calling RpcSmAllocate (or RpcSsAllocate). Upon return from the server stub, all the memory allocated by the RpcSs package is automatically freed. The following example shows how to enable the RpcSs package:

/* ACF file fragment */

[ 
    implicit_handle(handle_t GlobalHandle),
    enable_allocate
]
interface iface
{
}

/*Server management routine fragment. Replaces p=midl_user_allocate(size); */

    p=RpcSsAllocate(size);                /*raises exception */
    p=RpcSmAllocate(size, &status);       /*returns error code */

Your application can explicitly free memory by invoking the RpcSsFree or RpcSmFree function. Note that these functions do not actually free memory. They mark it for deletion. The RPC library releases the memory when your program calls RpcSsDisableAllocate or RpcSsDisableAllocate.

You can also enable the memory management environment for your application by calling the RpcSmEnableAllocate routine (and you can disable it by calling the RpcSmDisableAllocate routine). Once enabled, application code can allocate and deallocate memory by calling functions from the RpcSs package.

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。