OSF DCE Application Development Guide--Introduction and Style Guide

OSF DCE Application Development Guide—Introduction and Style Guide
This obeys all the rules for output parameters: the address passed to the call points to
valid storage, but the contents of that storage need not contain a meaningful value (in this
case, need not be a valid pointer). A simple rule of thumb for output parameters is to
declare a variable with one less asterisk than contained in the IDL (or RPC API)
declaration and pass its address when calling the operation.
6.2.1 Parameter Memory Management
RPC attempts to extend local procedure call parameter memory management semantics
to a situation in which the calling and called procedure no longer share the same memory
space. In effect, parameter memory has to be allocated twice, once on the client side,
once on the server side. Stubs do as much of the extra allocation work as possible so that
the complexities of parameter allocation are transparent to applications. In some cases,
however, applications may have to manage parameter memory in a way that differs from
the usual local procedure call semantics.
For the purposes of memory allocation, three classes of parameters must to be
considered:
Nonpointer types
Reference pointers
Full pointers
For all types, the client application supplies parameters to the client stub, which marshals
them for transmission to the server. The client application is entirely responsible for
managing the memory occupied by the passed parameters. On the server side, the server
stub allocates and frees all memory required for the received parameters themselves.
In the case of the pointer types, however, the application and stubs must manage memory
not only for the parameters themselves, but also for the pointed-to nodes. In this case,
the memory management requirements depend both on the pointer type and on the
parameter’s directional attributes.
The rules are described in the following sections.
6.2.2 Client Side Allocation
in parameters
For all pointer types, the client application must allocate memory for the
pointed-to nodes.
out parameters
For reference pointers, the client application must allocate memory for
the pointed-to nodes, unless the pointer is part of a data structure created
by server manager code. For parameters containing full pointers, the
stub allocates memory for the pointed-to nodes.
6 4 Tandem Computers Incorporated 124246