diff --git a/src/rx/xdr.c b/src/rx/xdr.c index 88f7772c99..3353b72c33 100644 --- a/src/rx/xdr.c +++ b/src/rx/xdr.c @@ -577,6 +577,15 @@ xdr_wrapstring(XDR * xdrs, char **cpp) } #endif +void +xdrfree_string(char **cpp) +{ + XDR xdrs; + memset(&xdrs, 0, sizeof(xdrs)); + xdrs.x_op = XDR_FREE; + (void)xdr_string(&xdrs, cpp, MAX_AFS_UINT32); +} + void * xdr_alloc(afs_int32 size) { diff --git a/src/rx/xdr_prototypes.h b/src/rx/xdr_prototypes.h index cd0355021e..f3baedc3c8 100644 --- a/src/rx/xdr_prototypes.h +++ b/src/rx/xdr_prototypes.h @@ -57,6 +57,7 @@ extern bool_t xdr_bytes(XDR * xdrs, char **cpp, extern bool_t xdr_union(XDR * xdrs, enum_t * dscmp, caddr_t unp, struct xdr_discrim *choices, xdrproc_t dfault); extern bool_t xdr_string(XDR * xdrs, char **cpp, u_int maxsize); +extern void xdrfree_string(char **cpp); extern bool_t xdr_wrapstring(XDR * xdrs, char **cpp); extern void * xdr_alloc(afs_int32 size); extern void xdr_free(xdrproc_t proc, void *obj); diff --git a/src/rxgen/rpc_cout.c b/src/rxgen/rpc_cout.c index 70bbd677cc..8eced7bae7 100644 --- a/src/rxgen/rpc_cout.c +++ b/src/rxgen/rpc_cout.c @@ -115,10 +115,25 @@ undefined(char *type) } +static void +print_xdrfree(char *name) +{ + f_print(fout, "void\n"); + f_print(fout, "xdrfree_%s(%s *objp)", name, name); + f_print(fout, "{\n"); + f_print(fout, "\tXDR xdrs;\n"); + f_print(fout, "\tmemset(&xdrs, 0, sizeof(xdrs));\n"); + f_print(fout, "\txdrs.x_op = XDR_FREE;\n"); + f_print(fout, "\t(void)xdr_%s(&xdrs, objp);\n", name); + f_print(fout, "}\n"); +} + static void print_header(definition * def) { space(); + print_xdrfree(def->def_name); + f_print(fout, "bool_t\n"); f_print(fout, "xdr_%s(XDR *xdrs, ", def->def_name); f_print(fout, "%s ", def->def_name); @@ -462,6 +477,7 @@ print_hout(declaration * dec) f_print(fout, ";\n"); f_print(fout, "bool_t xdr_%s(XDR *xdrs, %s *objp);\n", dec->name, dec->name); + f_print(fout, "void xdrfree_%s(%s *objp);\n", dec->name, dec->name); } } @@ -477,6 +493,8 @@ print_cout(declaration * dec) print_ifstat(1, dec->prefix, dec->type, dec->rel, dec->array_max, "objp", dec->name); print_trailer(); + + print_xdrfree(dec->name); } } diff --git a/src/rxgen/rpc_hout.c b/src/rxgen/rpc_hout.c index 0acbbbe33c..251ddc92ed 100644 --- a/src/rxgen/rpc_hout.c +++ b/src/rxgen/rpc_hout.c @@ -92,6 +92,8 @@ print_datadef(definition * def) if (def->def_kind != DEF_CONST && (!IsRxgenDefinition(def))) { f_print(fout, "bool_t xdr_%s(XDR *xdrs, %s *objp);\n", def->def_name, def->def_name); + f_print(fout, "void xdrfree_%s(%s *objp);\n", def->def_name, + def->def_name); } if (def->def_kind != DEF_CONST && (!IsRxgenDefinition(def))) { f_print(fout, "\n");