The stubs call the type_from_xmit function to convert data from its transmitted type to the type that is presented to the application. The function is defined as:
void __RPC_USER <type>_from_xmit (
<xmit_type> __RPC_FAR *,
<type> __RPC_FAR *);
The first parameter is a pointer to the transmitted data. The function sets the second parameter to point to the presented data.
The type_from_xmit function must manage memory for the presented type. The function must allocate memory for the entire data structure that starts at the address indicated by the second parameter, except for the parameter itself (the stub allocates memory for the root node and passes it to the function). The value of the second parameter cannot change during the call. The function can change the contents at that address.
In this example, the function DOUBLE_LINK_TYPE_from_xmit converts the sized array to a double-linked list. The function retains the valid pointer to the beginning of the list, frees memory associated with the rest of the list, then creates a new list that starts at the same pointer. The function uses a utility function, InsertNewNode, to append a list node to the end of the list and to assign the pNext and pPrevious pointers to appropriate values.
void __RPC_USER DOUBLE_LINK_TYPE_from_xmit(
DOUBLE_XMIT_TYPE __RPC_FAR * pArray,
DOUBLE_LINK_TYPE __RPC_FAR * pList)
{
DOUBLE_LINK_TYPE *pCurrent;
int i;
if (pArray->sSize <= 0) { // error checking
return;
}
if (pList == NULL) // if invalid, create the list head
pList = InsertNewNode(pArray->asNumber[0], NULL);
else {
DOUBLE_LINK_TYPE_free_inst(pList); // free all other nodes
pList->sNumber = pArray->asNumber[0];
pList->pNext = NULL;
}
pCurrent = pList;
for (i = 1; i < pArray->sSize; i++)
pCurrent = InsertNewNode(pArray->asNumber[i], pCurrent);
return;
}