about summary refs log tree commit diff
path: root/nis
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-12-04 06:27:06 +0000
committerUlrich Drepper <drepper@redhat.com>2005-12-04 06:27:06 +0000
commit56a5719e184c982c7e09cb4cc57cb6cd42eadef4 (patch)
tree085569f5075f11252046e01d3ae53e1e6f2d85a2 /nis
parent9069c5e963e530195745697d34f305faf45c0574 (diff)
downloadglibc-56a5719e184c982c7e09cb4cc57cb6cd42eadef4.tar.gz
glibc-56a5719e184c982c7e09cb4cc57cb6cd42eadef4.tar.xz
glibc-56a5719e184c982c7e09cb4cc57cb6cd42eadef4.zip
* nis/nis_table.c (nis_list): Optimize freeing and reallocation of
	result record.
Diffstat (limited to 'nis')
-rw-r--r--nis/nis_table.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/nis/nis_table.c b/nis/nis_table.c
index cfa7cef350..773380acac 100644
--- a/nis/nis_table.c
+++ b/nis/nis_table.c
@@ -296,6 +296,15 @@ nis_list (const_nis_name name, unsigned int flags,
 		      ibreq->ibr_srch.ibr_srch_val =
 			NIS_RES_OBJECT (res)->LI_data.li_attrs.li_attrs_val;
 		    }
+		/* The following is a non-obvious optimization.  A
+		   nis_freeresult call would call xdr_free as the
+		   following code.  But it also would unnecessarily
+		   free the result structure.  We avoid this here
+		   along with the necessary tests.  */
+#if 1
+		xdr_free ((xdrproc_t) _xdr_nis_result, (char *)res);
+		memset (res, '\0', sizeof (*res));
+#else
 		nis_freeresult (res);
 		res = calloc (1, sizeof (nis_result));
 		if (res == NULL)
@@ -306,6 +315,7 @@ nis_list (const_nis_name name, unsigned int flags,
 		    nis_free_directory (dir);
 		    return NULL;
 		  }
+#endif
 		first_try = 1; /* Try at first the old binding */
 		goto again;
 	      }