aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-12-04 07:10:47 +0000
committerUlrich Drepper <drepper@redhat.com>2005-12-04 07:10:47 +0000
commit707c7499fdae6795ea845a7fc002b47795e7e161 (patch)
tree83105cca6cc41d8aad0557958888426f17a301e8
parent56a5719e184c982c7e09cb4cc57cb6cd42eadef4 (diff)
downloadglibc-707c7499fdae6795ea845a7fc002b47795e7e161.tar
glibc-707c7499fdae6795ea845a7fc002b47795e7e161.tar.gz
glibc-707c7499fdae6795ea845a7fc002b47795e7e161.tar.bz2
glibc-707c7499fdae6795ea845a7fc002b47795e7e161.zip
(nis_list): One more reallocation optimization.
-rw-r--r--nis/nis_table.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/nis/nis_table.c b/nis/nis_table.c
index 773380acac..6761d37233 100644
--- a/nis/nis_table.c
+++ b/nis/nis_table.c
@@ -267,8 +267,8 @@ nis_list (const_nis_name name, unsigned int flags,
case NIS_PARTIAL:
case NIS_SUCCESS:
case NIS_S_SUCCESS:
- if (__type_of (NIS_RES_OBJECT (res)) == NIS_LINK_OBJ &&
- flags & FOLLOW_LINKS) /* We are following links. */
+ if (__type_of (NIS_RES_OBJECT (res)) == NIS_LINK_OBJ
+ && (flags & FOLLOW_LINKS)) /* We are following links. */
{
free (ibreq->ibr_name);
ibreq->ibr_name = NULL;
@@ -319,8 +319,8 @@ nis_list (const_nis_name name, unsigned int flags,
first_try = 1; /* Try at first the old binding */
goto again;
}
- else if ((flags & FOLLOW_PATH) &&
- NIS_RES_STATUS (res) == NIS_PARTIAL)
+ else if ((flags & FOLLOW_PATH)
+ && NIS_RES_STATUS (res) == NIS_PARTIAL)
{
if (!have_tablepath)
{
@@ -349,11 +349,21 @@ nis_list (const_nis_name name, unsigned int flags,
else
{
ibreq->ibr_name = strdup (ibreq->ibr_name);
+ /* 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));
+ if (ibreq->ibr_name == NULL)
+#else
nis_freeresult (res);
res = calloc (1, sizeof (nis_result));
if (res == NULL || ibreq->ibr_name == NULL)
+#endif
{
- free (ibreq->ibr_name);
free (res);
nis_free_request (ibreq);
if (have_tablepath)