/* XDR an indirect pointer xdr_reference is for recursively translating a structure that is referenced by a pointer inside the structure that is currently being translated. pp references a pointer to storage. If *pp is null the necessary storage is allocated. size is the sizeof the referneced structure. proc is the routine to handle the referenced structure.  */
bool_t xdr_reference(XDR *xdrs, char **pp, unsigned int size, xdrproc_t proc)
/* XDR an indirect pointer xdr_reference is for recursively translating a structure that is referenced by a pointer inside the structure that is currently being translated. pp references a pointer to storage. If *pp is null the necessary storage is allocated. size is the sizeof the referneced structure. proc is the routine to handle the referenced structure.  */
bool_t xdr_reference(XDR *xdrs, char **pp, unsigned int size, xdrproc_t proc)
{
    register char* loc = *pp;
    register bool_t stat;
    if (loc == NULL)
        switch (xdrs->x_op) {
        case XDR_FREE:
            return (TRUE);
        case XDR_DECODE:
            *pp = loc = (char*) rt_malloc(size);
            if (loc == NULL) {
                rt_kprintf("xdr_reference: out of memory\n");
                return (FALSE);
            }
            memset(loc, 0, (int) size);
            break;
        }
    stat = (*proc) (xdrs, loc, LASTUNSIGNED);
    if (xdrs->x_op == XDR_FREE) {
        rt_free(loc);
        *pp = NULL;
    }
    return (stat);
}