about summary refs log tree commit diff
path: root/nis/nis_getservlist.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-04-22 03:58:39 +0000
committerUlrich Drepper <drepper@redhat.com>2000-04-22 03:58:39 +0000
commit54eb84d0c769dbd974b21ffd9d41d48aff203a15 (patch)
tree62e967244da950de59f2ebb8ed4b9958136bba71 /nis/nis_getservlist.c
parente88e03a0451bba8f20faadcd5f214810770824f1 (diff)
downloadglibc-54eb84d0c769dbd974b21ffd9d41d48aff203a15.tar.gz
glibc-54eb84d0c769dbd974b21ffd9d41d48aff203a15.tar.xz
glibc-54eb84d0c769dbd974b21ffd9d41d48aff203a15.zip
Update.
	* nis/nis_findserv.c (__nis_findfastest): Improve memory handling.
	* nis/nis_print_group_entry.c (nis_print_group_entry): Use alloca
	instead of malloc.
	* nis/nis_subr.c: Use __builtin_expect.
	* nis/ypclnt.c: Likewise.
	* nis/nis_getservlist.c: Likewise.
	* nis/nis_creategroup.c: Likewise.
Diffstat (limited to 'nis/nis_getservlist.c')
-rw-r--r--nis/nis_getservlist.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/nis/nis_getservlist.c b/nis/nis_getservlist.c
index 5d93f38d9a..0b4096a779 100644
--- a/nis/nis_getservlist.c
+++ b/nis/nis_getservlist.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -39,7 +39,7 @@ nis_getservlist (const_nis_name dir)
       serv =
 	malloc (sizeof (nis_server *) *
 		(NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len + 1));
-      if (serv == NULL)
+      if (__builtin_expect (serv == NULL, 0))
 	return NULL;
 
       for (i = 0; i < NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_len;
@@ -48,10 +48,13 @@ nis_getservlist (const_nis_name dir)
 	  server =
 	    &NIS_RES_OBJECT (res)->DI_data.do_servers.do_servers_val[i];
 	  serv[i] = calloc (1, sizeof (nis_server));
+	  if (__builtin_expect (serv[i] == NULL, 0))
+	    return NULL;
+
 	  if (server->name != NULL)
 	    {
 	      serv[i]->name = strdup (server->name);
-	      if (serv[i]->name == NULL)
+	      if (__builtin_expect (serv[i]->name == NULL, 0))
 		return NULL;
 	    }
 
@@ -62,7 +65,7 @@ nis_getservlist (const_nis_name dir)
 
               serv[i]->ep.ep_val =
 		malloc (server->ep.ep_len * sizeof (endpoint));
-	      if (serv[i]->ep.ep_val == NULL)
+	      if (__builtin_expect (serv[i]->ep.ep_val == NULL, 0))
 		return NULL;
 
               for (j = 0; j < serv[i]->ep.ep_len; ++j)
@@ -90,9 +93,8 @@ nis_getservlist (const_nis_name dir)
           serv[i]->pkey.n_len = server->pkey.n_len;
           if (server->pkey.n_len > 0)
             {
-              serv[i]->pkey.n_bytes =
-                malloc (server->pkey.n_len);
-              if (serv[i]->pkey.n_bytes == NULL)
+              serv[i]->pkey.n_bytes = malloc (server->pkey.n_len);
+              if (__builtin_expect (serv[i]->pkey.n_bytes == NULL, 0))
                 return NULL;
               memcpy (serv[i]->pkey.n_bytes, server->pkey.n_bytes,
                       server->pkey.n_len);
@@ -105,7 +107,7 @@ nis_getservlist (const_nis_name dir)
   else
     {
       serv = malloc (sizeof (nis_server *));
-      if (serv != NULL)
+      if (__builtin_expect (serv != NULL, 0))
 	serv[0] = NULL;
     }