CITS3002 Computer Networks |
← prev | CITS3002 | help3002 | CITS3002 schedule | ||||
Converting complex data structures, continuedExample: If we wished to XDR encode a pointer to the person structure declared as
we would convert it using
If the XDR stream indicates an encode operation the function follows the pointer and encodes the data it points to by calling xdr_person(). If the XDR stream indicates a decode operation and *pp is NULL the routine allocates memory to hold the structure and makes pp point to that area. The routine then decodes the data by calling xdr_person() and places the decoded structure into the memory pointed to by pp. A related routine called xdr_pointer() exists which more correctly understands NULL pointers.
This facility can be used to create functions which encode/decode linked
lists and other arbitrarily complex data structures.
CITS3002 Computer Networks, Lecture 10, Architecture independent applications, p23, 8th May 2024.
|