]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
* nis/nis_table.c (nis_list): Optimize freeing and reallocation of
authorUlrich Drepper <drepper@redhat.com>
Sun, 4 Dec 2005 06:27:06 +0000 (06:27 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sun, 4 Dec 2005 06:27:06 +0000 (06:27 +0000)
result record.

ChangeLog
nis/nis_table.c

index ee6b092dde295c151aded07fb6fb4b358b8734f5..654d032f08e0e206dc134c377958abb3bcb8d63d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2005-12-03  Ulrich Drepper  <drepper@redhat.com>
 
+       * nis/nis_table.c (nis_list): Optimize freeing and reallocation of
+       result record.
+
        * nis/nss_nisplus/nisplus-network.c (_nss_nisplus_getnetbyaddr_r):
        Better sized buffers.  Correct error case handling.
        * nis/nis_error.c (nis_sperror_r): Let snprintf determine whether
index cfa7cef350800263dc6486eefb23f779aa55881c..773380acac20d20a043768377c6460d4bd9da1a4 100644 (file)
@@ -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;
              }