OSF DCE Application Development Guide--Core Components
Interface Definition Language
The syntax of the routine is as follows:
void rpc_ss_swap_client_alloc_free (
idl_void_p_t (*p_allocate)(
idl_size_t size),
void (*p_free)(
idl_void_p_t ptr),
idl_void_p_t (**p_p_old_allocate)(
idl_size_t size),
void (**p_p_old_free)(
idl_void_p_t ptr)
);
The p_allocate parameter points to a routine that has the same procedure declaration as
the malloc() routine, and is used by the client stub when performing memory allocation.
The p_free parameter points to a routine that has the same procedure declaration as the
free( ) routine, and is used by the client stub to free memory. The p_p_old_allocate
parameter points to a pointer to a routine that has the same procedure declaration as the
malloc( ) routine, and is the default routine used for memory allocation in the client stub.
The p_p_old_free parameter points to a pointer to a routine that has the same procedure
declaration as the free() routine, and is used for memory release in the client.
17.14.7.10 Use of Thread Handles in Memory Management
There are two situations where control of memory management requires the use of
thread handles. The more common situation is when the manager thread spawns
additional threads. The less common situation is when a program transitions from being
a client to being a server, then reverts to being a client.
17.14.7.10.1 Spawning Threads
When a remote procedure call invokes the manager code, the manager code may wish to
spawn additional threads to complete the task for which it was called. To spawn
additional threads that are able to perform memory management, the manager code must
first call the rpc_ss_get_thread_handle( ) routine to get its thread handle and then pass
that thread handle to each spawned thread. Each spawned thread that uses the rpc_ss_-
allocate() and rpc_ss_free() routines for memory management first calls the rpc_ss_-
set_thread_handle( ) routine by using the handle obtained by the original manager
thread.
These routine calls allow the manager and its spawned threads to share a common
memory management environment. This common environment enables memory
allocated by the spawned threads to be used in returned parameters, and causes all
allocations in the common memory management environment to be released when the
manager thread returns to the server stub.
124245 Tandem Computers Incorporated 17− 51