about summary refs log tree commit diff
path: root/sunrpc/xdr_array.c
diff options
context:
space:
mode:
Diffstat (limited to 'sunrpc/xdr_array.c')
-rw-r--r--sunrpc/xdr_array.c152
1 files changed, 81 insertions, 71 deletions
diff --git a/sunrpc/xdr_array.c b/sunrpc/xdr_array.c
index 6b2adb2331..a58fade734 100644
--- a/sunrpc/xdr_array.c
+++ b/sunrpc/xdr_array.c
@@ -41,7 +41,7 @@ static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
  */
 
 #include <stdio.h>
-
+#include <string.h>
 #include <rpc/types.h>
 #include <rpc/xdr.h>
 
@@ -56,68 +56,76 @@ static char sccsid[] = "@(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";
  * xdr procedure to call to handle each element of the array.
  */
 bool_t
-xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
-	register XDR *xdrs;
-	caddr_t *addrp;		/* array pointer */
-	u_int *sizep;		/* number of elements */
-	u_int maxsize;		/* max numberof elements */
-	u_int elsize;		/* size in bytes of each element */
-	xdrproc_t elproc;	/* xdr routine to handle each element */
+xdr_array (xdrs, addrp, sizep, maxsize, elsize, elproc)
+     XDR *xdrs;
+     caddr_t *addrp;		/* array pointer */
+     u_int *sizep;		/* number of elements */
+     u_int maxsize;		/* max numberof elements */
+     u_int elsize;		/* size in bytes of each element */
+     xdrproc_t elproc;		/* xdr routine to handle each element */
 {
-	register u_int i;
-	register caddr_t target = *addrp;
-	register u_int c;  /* the actual element count */
-	register bool_t stat = TRUE;
-	register u_int nodesize;
+  u_int i;
+  caddr_t target = *addrp;
+  u_int c;		/* the actual element count */
+  bool_t stat = TRUE;
+  u_int nodesize;
 
-	/* like strings, arrays are really counted arrays */
-	if (! xdr_u_int(xdrs, sizep)) {
-		return (FALSE);
-	}
-	c = *sizep;
-	if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) {
-		return (FALSE);
-	}
-	nodesize = c * elsize;
+  /* like strings, arrays are really counted arrays */
+  if (!xdr_u_int (xdrs, sizep))
+    {
+      return FALSE;
+    }
+  c = *sizep;
+  if ((c > maxsize) && (xdrs->x_op != XDR_FREE))
+    {
+      return FALSE;
+    }
+  nodesize = c * elsize;
 
-	/*
-	 * if we are deserializing, we may need to allocate an array.
-	 * We also save time by checking for a null array if we are freeing.
-	 */
+  /*
+   * if we are deserializing, we may need to allocate an array.
+   * We also save time by checking for a null array if we are freeing.
+   */
+  if (target == NULL)
+    switch (xdrs->x_op)
+      {
+      case XDR_DECODE:
+	if (c == 0)
+	  return TRUE;
+	*addrp = target = mem_alloc (nodesize);
 	if (target == NULL)
-		switch (xdrs->x_op) {
-		case XDR_DECODE:
-			if (c == 0)
-				return (TRUE);
-			*addrp = target = mem_alloc(nodesize);
-			if (target == NULL) {
-				(void) fprintf(stderr,
-					"xdr_array: out of memory\n");
-				return (FALSE);
-			}
-			bzero(target, nodesize);
-			break;
+	  {
+	    (void) fprintf (stderr,
+			    "xdr_array: out of memory\n");
+	    return FALSE;
+	  }
+	bzero (target, nodesize);
+	break;
 
-		case XDR_FREE:
-			return (TRUE);
-	}
+      case XDR_FREE:
+	return TRUE;
+      default:
+	break;
+      }
 
-	/*
-	 * now we xdr each element of array
-	 */
-	for (i = 0; (i < c) && stat; i++) {
-		stat = (*elproc)(xdrs, target, LASTUNSIGNED);
-		target += elsize;
-	}
+  /*
+   * now we xdr each element of array
+   */
+  for (i = 0; (i < c) && stat; i++)
+    {
+      stat = (*elproc) (xdrs, target, LASTUNSIGNED);
+      target += elsize;
+    }
 
-	/*
-	 * the array may need freeing
-	 */
-	if (xdrs->x_op == XDR_FREE) {
-		mem_free(*addrp, nodesize);
-		*addrp = NULL;
-	}
-	return (stat);
+  /*
+   * the array may need freeing
+   */
+  if (xdrs->x_op == XDR_FREE)
+    {
+      mem_free (*addrp, nodesize);
+      *addrp = NULL;
+    }
+  return stat;
 }
 
 /*
@@ -131,22 +139,24 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
  * > xdr_elem: routine to XDR each element
  */
 bool_t
-xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem)
-	register XDR *xdrs;
-	register char *basep;
-	register u_int nelem;
-	register u_int elemsize;
-	register xdrproc_t xdr_elem;
+xdr_vector (xdrs, basep, nelem, elemsize, xdr_elem)
+     XDR *xdrs;
+     char *basep;
+     u_int nelem;
+     u_int elemsize;
+     xdrproc_t xdr_elem;
 {
-	register u_int i;
-	register char *elptr;
+  u_int i;
+  char *elptr;
 
-	elptr = basep;
-	for (i = 0; i < nelem; i++) {
-		if (! (*xdr_elem)(xdrs, elptr, LASTUNSIGNED)) {
-			return(FALSE);
-		}
-		elptr += elemsize;
+  elptr = basep;
+  for (i = 0; i < nelem; i++)
+    {
+      if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED))
+	{
+	  return FALSE;
 	}
-	return(TRUE);
+      elptr += elemsize;
+    }
+  return TRUE;
 }