Skip to content

Commit

Permalink
* sunrpc/xdr_array.c (xdr_array): Use calloc instead of malloc&bzero.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Drepper committed May 4, 2006
1 parent 48be311 commit 5e65a53
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
2006-05-04 Ulrich Drepper <drepper@redhat.com>

* sunrpc/xdr_array.c (xdr_array): Use calloc instead of malloc&bzero.

* sunrpc/key_call.c (__rpc_thread_key_cleanup): Also free
client->cl_auth.

7 changes: 2 additions & 5 deletions sunrpc/xdr_array.c
Original file line number Diff line number Diff line change
@@ -74,7 +74,6 @@ xdr_array (xdrs, addrp, sizep, maxsize, elsize, elproc)
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 (!INTUSE(xdr_u_int) (xdrs, sizep))
@@ -90,7 +89,6 @@ xdr_array (xdrs, addrp, sizep, maxsize, elsize, elproc)
{
return FALSE;
}
nodesize = c * elsize;

/*
* if we are deserializing, we may need to allocate an array.
@@ -102,13 +100,12 @@ xdr_array (xdrs, addrp, sizep, maxsize, elsize, elproc)
case XDR_DECODE:
if (c == 0)
return TRUE;
*addrp = target = mem_alloc (nodesize);
*addrp = target = calloc (c, elsize);
if (target == NULL)
{
(void) __fxprintf (NULL, "%s", _("xdr_array: out of memory\n"));
return FALSE;
}
__bzero (target, nodesize);
break;

case XDR_FREE:
@@ -131,7 +128,7 @@ xdr_array (xdrs, addrp, sizep, maxsize, elsize, elproc)
*/
if (xdrs->x_op == XDR_FREE)
{
mem_free (*addrp, nodesize);
mem_free (*addrp, c * elsize);
*addrp = NULL;
}
return stat;

0 comments on commit 5e65a53

Please sign in to comment.