Memory Allocation With XDR

XDR routines normally serialize and deserialize data. XDR routines often automatically allocate
memory and free automatically allocated memory. The convention is to use a
NULL pointer to an array or structure to indicate that an XDR
function must allocate memory when deserializing. The next example, xdr_chararr1(), processes a
fixed array of bytes with length SIZE and cannot allocate memory if
needed:

If space has already been allocated in chararr, it can be called
from a server as follows.

char chararr[SIZE];
svc_getargs(transp, xdr_chararr1, chararr);

Any structure through which data is passed to XDR or RPC routines
must be allocated so that its base address is at an architecture-dependent
boundary. An XDR routine that does the allocation must be written so
that it can:

Allocate memory when a caller requests

Return the pointer to any memory it allocates

In the following example, the second argument is a NULL pointer, meaning
that memory should be allocated to hold the data being deserialized.