PreviousNext

Parameter Semantics

RPC calls and the RPC API specify directional attributes for their parameters, even though such attributes are not formally supported by C. As a general rule, an [in] parameter is one that must be passed with a meaningful value and an [out] parameter is one whose value will be changed by the call. An [in,out] parameter is therefore one which must have a meaningful value on input and which may be changed on output.

The following table summarizes parameter semantics:


Parameter Semantics

Semantics Meaningful value input Changed on output
[in] yes no
[out] no yes
[in,out] yes yes
An [out] or( [in,out]) parameter is one whose value is changed by the call, so it must be passed by reference, that is, as a pointer to the datum of interest. RPCs and the RPC APIs therefore always specify output parameters as pointers. The address passed must always point to valid storage. For example, the ubiquitous status parameter may be declared in the IDL as follows:

[out] error_status_t *status

The application code then needs to declare a variable such as the following, and pass it as &st to each RPC:

error_status_t st;

When a call allocates storage for an output parameter, it is declared as a pointer to a pointer. For example:

rpc_binding_vector_t **binding_vector

The application follows the same rule as in the status case, declaring a variable such as the following, and then passing this as &binding_vec:

rpc_binding_vector_t *binding_vec

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.

More:

Parameter Memory Management

Client Side Allocation

Server Side Allocation