OSF DCE Application Development Guide--Introduction and Style Guide

OSF DCE Application Development Guide—Introduction and Style Guide
An application must be very cautious if it attempts to use pointer parameters in a way
that contradicts such semantics: for example, by returning a pointer to static global
storage on the server. In such a case, the server and client versions of such storage can
easily become inconsistent. A context handle, which the client must not modify, is
typically what you want in such a case.
The client code for the linked list test is as follows:
link_t first, *element;
int i;
first.value = 2;
first.next = NULL;
for (i=0;i<8; i++)
ptr_test2(binding_h, &first, &status);
element = &first;
while (element->next)
{
printf("%i, ", element->value);
element = element->next;
}
printf("%i0, element->value);
The client passes in the head element, and then calls the server several times to add more
elements to the list. Finally, the client prints out the list.
The next pointer example illustrates how the stubs automatically allocate memory for an
[out] parameter. The client application allocates a NULL pointer to the data structure of
interest and passes the address of this pointer as the [out] parameter. The server manager
allocates a structure, and on return the client stub allocates it too, automatically.
The .idl declaration is as follows:
typedef struct {
[ref] unsigned32 *value;
} number;
typedef [ptr] number *number_ptr;
void ptr_test3(
[in] handle_t handle,
[out, ref] number_ptr *client_ptr,
[out] error_status_t *status
);
The server manager operation is then as follows:
void
ptr_test3(
handle_t handle,
number_ptr *client_ptr,
error_status_t *status
)
{
6− 16 Tandem Computers Incorporated 124246