From d7749751df230d919188546106b61bd2dbb8974c Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 1 Apr 2009 17:37:50 +0000 Subject: [PATCH] xdr-free-20090401 LICENSE MIT add xdr_free() and export it from afsrpc.dll. This permits applications to free memory allocated within the xdr routines with the same run time library memory management routines as was used to allocate it. This is necessary on Windows to prevent memory corruption. VL_GetAddrsU() is an example where a xdr array is allocated in the library and must be freed by the application. --- src/libafsrpc/afsrpc.def | 1 + src/rx/xdr.c | 6 ++++++ src/rx/xdr_prototypes.h | 1 + 3 files changed, 8 insertions(+) diff --git a/src/libafsrpc/afsrpc.def b/src/libafsrpc/afsrpc.def index 8459dc24f..54c31d183 100644 --- a/src/libafsrpc/afsrpc.def +++ b/src/libafsrpc/afsrpc.def @@ -244,6 +244,7 @@ EXPORTS rx_WritevAlloc @249 rx_ReadProc32 @250 rx_WriteProc32 @251 + xdr_free @252 ; for performance testing rx_TSFPQGlobSize @2001 DATA diff --git a/src/rx/xdr.c b/src/rx/xdr.c index 776c2a12d..4819b6e48 100644 --- a/src/rx/xdr.c +++ b/src/rx/xdr.c @@ -584,4 +584,10 @@ xdr_wrapstring(XDR * xdrs, char **cpp) return (FALSE); } #endif + +void +xdr_free(void *x, afs_int32 size) +{ + osi_free(x, size); +} #endif /* NeXT */ diff --git a/src/rx/xdr_prototypes.h b/src/rx/xdr_prototypes.h index ef53d87f8..a24f928bd 100644 --- a/src/rx/xdr_prototypes.h +++ b/src/rx/xdr_prototypes.h @@ -58,6 +58,7 @@ 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 bool_t xdr_wrapstring(XDR * xdrs, char **cpp); +extern void xdr_free(void *x, afs_int32 size); /* xdr_float.c */ -- 2.39.5