aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sunrpc/xdr_mem.c')
-rw-r--r--sunrpc/xdr_mem.c53
1 files changed, 44 insertions, 9 deletions
diff --git a/sunrpc/xdr_mem.c b/sunrpc/xdr_mem.c
index 481a8664b5..8e88e41ea2 100644
--- a/sunrpc/xdr_mem.c
+++ b/sunrpc/xdr_mem.c
@@ -47,13 +47,13 @@ static char sccsid[] = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";
#include <rpc/rpc.h>
static bool_t xdrmem_getlong (XDR *, long *);
-static bool_t xdrmem_putlong (XDR *, long *);
+static bool_t xdrmem_putlong (XDR *, const long *);
static bool_t xdrmem_getbytes (XDR *, caddr_t, u_int);
-static bool_t xdrmem_putbytes (XDR *, caddr_t, u_int);
-static u_int xdrmem_getpos (XDR *);
+static bool_t xdrmem_putbytes (XDR *, const caddr_t, u_int);
+static u_int xdrmem_getpos (const XDR *);
static bool_t xdrmem_setpos (XDR *, u_int);
static long *xdrmem_inline (XDR *, int);
-static void xdrmem_destroy (XDR *);
+static void xdrmem_destroy (const XDR *);
static const struct xdr_ops xdrmem_ops =
{
@@ -74,7 +74,7 @@ static const struct xdr_ops xdrmem_ops =
void
xdrmem_create (xdrs, addr, size, op)
XDR *xdrs;
- caddr_t addr;
+ const caddr_t addr;
u_int size;
enum xdr_op op;
{
@@ -85,11 +85,21 @@ xdrmem_create (xdrs, addr, size, op)
xdrs->x_handy = size;
}
+/*
+ * Nothing needs to be done for the memory case. The argument is clearly
+ * const.
+ */
+
static void
-xdrmem_destroy (XDR *xdrs)
+xdrmem_destroy (const XDR *xdrs)
{
}
+/*
+ * Gets the next word from the memory referenced by xdrs and places it
+ * in the long pointed to by lp. It then increments the private word to
+ * point at the next element. Neither object pointed to is const
+ */
static bool_t
xdrmem_getlong (xdrs, lp)
XDR *xdrs;
@@ -103,10 +113,15 @@ xdrmem_getlong (xdrs, lp)
return TRUE;
}
+/*
+ * Puts the long pointed to by lp in the memory referenced by xdrs. It
+ * then increments the private word to point at the next element. The
+ * long pointed at is const
+ */
static bool_t
xdrmem_putlong (xdrs, lp)
XDR *xdrs;
- long *lp;
+ const long *lp;
{
if ((xdrs->x_handy -= 4) < 0)
@@ -116,6 +131,12 @@ xdrmem_putlong (xdrs, lp)
return TRUE;
}
+/*
+ * Gets an unaligned number of bytes from the xdrs structure and writes them
+ * to the address passed in addr. Be very careful when calling this routine
+ * as it could leave the xdrs pointing to an unaligned structure which is not
+ * a good idea. None of the things pointed to are const.
+ */
static bool_t
xdrmem_getbytes (xdrs, addr, len)
XDR *xdrs;
@@ -130,10 +151,14 @@ xdrmem_getbytes (xdrs, addr, len)
return TRUE;
}
+/*
+ * The complementary function to the above. The same warnings apply about
+ * unaligned data. The source address is const.
+ */
static bool_t
xdrmem_putbytes (xdrs, addr, len)
XDR *xdrs;
- caddr_t addr;
+ const caddr_t addr;
u_int len;
{
@@ -144,14 +169,21 @@ xdrmem_putbytes (xdrs, addr, len)
return TRUE;
}
+/*
+ * Not sure what this one does. But it clearly doesn't modify the contents
+ * of xdrs. **FIXME** does this not assume u_int == u_long?
+ */
static u_int
xdrmem_getpos (xdrs)
- XDR *xdrs;
+ const XDR *xdrs;
{
return (u_long) xdrs->x_private - (u_long) xdrs->x_base;
}
+/*
+ * xdrs modified
+ */
static bool_t
xdrmem_setpos (xdrs, pos)
XDR *xdrs;
@@ -167,6 +199,9 @@ xdrmem_setpos (xdrs, pos)
return TRUE;
}
+/*
+ * xdrs modified
+ */
static long *
xdrmem_inline (xdrs, len)
XDR *xdrs;