OSF DCE Application Development Guide--Core Components
OSF DCE Application Development Guide—Core Components
RPC server stubs do not allocate memory. Instead, they rely on the manager code—the
code that the server stubs call—to allocate it for them.
The following sections gives guidelines for how client code and manager code should
use the the various allocation and free routines provided with DCE.
Note: DCE provides two versions of DCE RPC stub support routines. The
rpc_ss_*() routines raise an exception, while the rpc_sm_*() routines
return an error status value. In all other ways, the routines are identical. It
is generally recommended that you use the rpc_sm_*()routines instead of
the rpc_ss_*() routines for compliance with the Application Environment
Specification/Distributed Computing.
16.1.1 Usingthe Memory Management Defaults
If it does not matter to the client code which memory allocation routine the RPC client
stubs use, the client code should call the rpc_ss_client_free( ) routine to free any
memory that the client stub allocates and returns. The rpc_ss_client_free( ) routine uses
the current free routine that is in effect. Client code that uses rpc_ss_client_free( ) must
use caution if it calls other routines before it frees all of the pieces of allocated storage
with rpc_ss_client_free(), because it is possible that the called code has been written so
that it swaps in a different allocation/free pair without reestablishing the previous
allocation/free pair on exit.
16.1.2 Usingrpc_ss_allocate and rpc_ss_free
Both client code and manager code can use rpc_ss_allocate() and rpc_ss_free( ). The
next sections describe how.
16.1.2.1 Using rpc_ss_allocate and rpc_ss_free in Manager Code
Manager code uses either the rpc_ss_allocate() and rpc_ss_free( ) routines or the
operating system allocation and free routines to allocate and free memory.
Manager code uses rpc_ss_allocate() to allocate storage for data that the server stub is
to send back to the client. Manager code can either use rpc_ss_free( ) to free the storage
explicitly, or it can rely on the server stub to free it. After the server stub marshalls the
output parameters, it releases any storage that the manager code has allocated with
rpc_ss_allocate().
Manager code can also use the rpc_ss_free() routine to release storage pointed to by a
full pointer in an input parameter and have the freeing of the memory reflected on return
to the calling application if the reflect_deletions attribute has been specified as an
operation attribute in the interface definition. See Chapter 17 for instructions on how to
16 −2 Tandem Computers Incorporated 124245