summary refs log tree commit diff
path: root/sunrpc/svc_udp.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /sunrpc/svc_udp.c
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.xz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip
2.5-18.1
Diffstat (limited to 'sunrpc/svc_udp.c')
-rw-r--r--sunrpc/svc_udp.c43
1 files changed, 13 insertions, 30 deletions
diff --git a/sunrpc/svc_udp.c b/sunrpc/svc_udp.c
index 45f99440b2..dfeb6de70f 100644
--- a/sunrpc/svc_udp.c
+++ b/sunrpc/svc_udp.c
@@ -149,12 +149,7 @@ svcudp_bufcreate (sock, sendsz, recvsz)
   buf = mem_alloc (((MAX (sendsz, recvsz) + 3) / 4) * 4);
   if (xprt == NULL || su == NULL || buf == NULL)
     {
-#ifdef USE_IN_LIBIO
-      if (_IO_fwide (stderr, 0) > 0)
-	(void) __fwprintf (stderr, L"%s", _("svcudp_create: out of memory\n"));
-      else
-#endif
-	(void) fputs (_("svcudp_create: out of memory\n"), stderr);
+      (void) __fxprintf (NULL, "%s", _("svcudp_create: out of memory\n"));
       mem_free (xprt, sizeof (SVCXPRT));
       mem_free (su, sizeof (*su));
       mem_free (buf, ((MAX (sendsz, recvsz) + 3) / 4) * 4);
@@ -176,14 +171,8 @@ svcudp_bufcreate (sock, sendsz, recvsz)
        + sizeof(struct cmsghdr) + sizeof (struct in_pktinfo))
       > sizeof (xprt->xp_pad))
     {
-# ifdef USE_IN_LIBIO
-      if (_IO_fwide (stderr, 0) > 0)
-	(void) __fwprintf (stderr, L"%s",
-			   _("svcudp_create: xp_pad is too small for IP_PKTINFO\n"));
-      else
-# endif
-	(void) fputs (_("svcudp_create: xp_pad is too small for IP_PKTINFO\n"),
-		      stderr);
+      (void) __fxprintf (NULL,"%s", _("\
+svcudp_create: xp_pad is too small for IP_PKTINFO\n"));
       return NULL;
     }
   pad = 1;
@@ -411,22 +400,14 @@ svcudp_destroy (xprt)
 
 #define SPARSENESS 4		/* 75% sparse */
 
-#ifdef USE_IN_LIBIO
-# define CACHE_PERROR(msg)	\
-	if (_IO_fwide (stderr, 0) > 0)					      \
-		(void) __fwprintf(stderr, L"%s\n", msg);		      \
-	else								      \
-		(void) fprintf(stderr, "%s\n", msg)
-#else
-# define CACHE_PERROR(msg)	\
-	(void) fprintf(stderr,"%s\n", msg)
-#endif
+#define CACHE_PERROR(msg)	\
+	(void) __fxprintf(NULL, "%s\n", msg)
 
 #define ALLOC(type, size)	\
 	(type *) mem_alloc((unsigned) (sizeof(type) * (size)))
 
-#define BZERO(addr, type, size)	 \
-	__bzero((char *) addr, sizeof(type) * (int) (size))
+#define CALLOC(type, size)	\
+  (type *) calloc (sizeof (type), size)
 
 /*
  * An entry in the cache
@@ -501,20 +482,21 @@ svcudp_enablecache (SVCXPRT *transp, u_long size)
     }
   uc->uc_size = size;
   uc->uc_nextvictim = 0;
-  uc->uc_entries = ALLOC (cache_ptr, size * SPARSENESS);
+  uc->uc_entries = CALLOC (cache_ptr, size * SPARSENESS);
   if (uc->uc_entries == NULL)
     {
+      mem_free (uc, sizeof (struct udp_cache));
       CACHE_PERROR (_("enablecache: could not allocate cache data"));
       return 0;
     }
-  BZERO (uc->uc_entries, cache_ptr, size * SPARSENESS);
-  uc->uc_fifo = ALLOC (cache_ptr, size);
+  uc->uc_fifo = CALLOC (cache_ptr, size);
   if (uc->uc_fifo == NULL)
     {
+      mem_free (uc->uc_entries, size * SPARSENESS);
+      mem_free (uc, sizeof (struct udp_cache));
       CACHE_PERROR (_("enablecache: could not allocate cache fifo"));
       return 0;
     }
-  BZERO (uc->uc_fifo, cache_ptr, size);
   su->su_cache = (char *) uc;
   return 1;
 }
@@ -564,6 +546,7 @@ cache_set (SVCXPRT *xprt, u_long replylen)
       newbuf = mem_alloc (su->su_iosz);
       if (newbuf == NULL)
 	{
+	  mem_free (victim, sizeof (struct cache_node));
 	  CACHE_PERROR (_("cache_set: could not allocate new rpc_buffer"));
 	  return;
 	}