]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Update.
authorUlrich Drepper <drepper@redhat.com>
Mon, 29 Mar 2004 21:46:58 +0000 (21:46 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 29 Mar 2004 21:46:58 +0000 (21:46 +0000)
* nis/nss_nis/nis-rpc.c (saveit): Improve memory.  No need to
allocate multiple blocks.
(internal_nis_endrpcent): Adjust accordingly.
* nis/nss_nis/nis-proto.c (saveit): Improve memory.  No need to
allocate multiple blocks.
(internal_nis_endprotoent): Adjust accordingly.
* nis/nss_nis/nis-initgroups.c (saveit): Improve memory.  No need
to allocate multiple blocks.
(_nss_nis_initgroups_dyn): Adjust accordingly.
* nis/nss_nis/nis-ethers.c (saveit): Improve memory.  No need to
allocate multiple blocks.
(internal_nis_endetherent): Adjust accordingly.
* nis/nss_nis/nis-service.c (saveit): Improve memory.  No need to
allocate multiple blocks.
(internal_nis_endservent): Adjust accordingly.

ChangeLog
nis/nss_nis/nis-ethers.c
nis/nss_nis/nis-initgroups.c
nis/nss_nis/nis-proto.c
nis/nss_nis/nis-rpc.c
nis/nss_nis/nis-service.c

index 5bc34ad3c78e65c5fbdea8de9d8ae06e5850c69b..20956be9f07225210d4209f9c7cb09663e5ddae7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2004-03-29  Ulrich Drepper  <drepper@redhat.com>
 
+       * nis/nss_nis/nis-rpc.c (saveit): Improve memory.  No need to
+       allocate multiple blocks.
+       (internal_nis_endrpcent): Adjust accordingly.
+       * nis/nss_nis/nis-proto.c (saveit): Improve memory.  No need to
+       allocate multiple blocks.
+       (internal_nis_endprotoent): Adjust accordingly.
+       * nis/nss_nis/nis-initgroups.c (saveit): Improve memory.  No need
+       to allocate multiple blocks.
+       (_nss_nis_initgroups_dyn): Adjust accordingly.
+       * nis/nss_nis/nis-ethers.c (saveit): Improve memory.  No need to
+       allocate multiple blocks.
+       (internal_nis_endetherent): Adjust accordingly.
+       * nis/nss_nis/nis-service.c (saveit): Improve memory.  No need to
+       allocate multiple blocks.
+       (internal_nis_endservent): Adjust accordingly.
+
        * nss/getXXbyYY_r.c: Return 0 for NSS_STATUS_NOTFOUND.
 
 2004-03-26  Thorsten Kukuk  <kukuk@suse.de>
index 713fe31e93e4bcca1169bf1a252074eefed3d1dd..328d61f6c56a19bd36bed965bc13cb0e49fc4211 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
 
@@ -40,8 +40,8 @@ __libc_lock_define_initialized (static, lock)
 
 struct response
 {
-  char *val;
   struct response *next;
+  char val[0];
 };
 
 static struct response *start;
@@ -56,26 +56,18 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval,
 
   if (inkey && inkeylen > 0 && inval && invallen > 0)
     {
+      struct response *newp = malloc (sizeof (struct response) + invallen + 1);
+      if (newp == NULL)
+       return YP_FALSE; /* We have no error code for out of memory */
+
       if (start == NULL)
-       {
-         start = malloc (sizeof (struct response));
-         if (start == NULL)
-           return YP_FALSE;
-         next = start;
-       }
+       start = newp;
       else
-       {
-         next->next = malloc (sizeof (struct response));
-         if (next->next == NULL)
-           return YP_FALSE;
-         next = next->next;
-       }
-      next->next = NULL;
-      next->val = malloc (invallen + 1);
-      if (next->val == NULL)
-       return YP_FALSE;
-      strncpy (next->val, inval, invallen);
-      next->val[invallen] = '\0';
+       next->next = newp;
+      next = newp;
+
+      newp->next = NULL;
+      *((char *) mempcpy (newp->val, inval, invallen)) = '\0';
     }
 
   return 0;
@@ -86,8 +78,6 @@ internal_nis_endetherent (void)
 {
   while (start != NULL)
     {
-      if (start->val != NULL)
-       free (start->val);
       next = start;
       start = start->next;
       free (next);
index e3a8f57fcc728762e91b5e83da3041e4df422027..4c979889b702c1611f9c8f20a930c8698d8ee614 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2000, 2002, 2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
 
@@ -38,8 +38,8 @@
 
 struct response_t
 {
-  char *val;
   struct response_t *next;
+  char val[0];
 };
 
 struct intern_t
@@ -60,26 +60,19 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval,
 
   if (inkey && inkeylen > 0 && inval && invallen > 0)
     {
+      struct response_t *newp = malloc (sizeof (struct response_t)
+                                       + invallen + 1);
+      if (newp == NULL)
+       return YP_FALSE; /* We have no error code for out of memory */
+
       if (intern->start == NULL)
-        {
-          intern->start = malloc (sizeof (struct response_t));
-         if (intern->start == NULL)
-           return YP_FALSE;
-          intern->next = intern->start;
-        }
+       intern->start = newp;
       else
-        {
-          intern->next->next = malloc (sizeof (struct response_t));
-         if (intern->next->next == NULL)
-           return YP_FALSE;
-          intern->next = intern->next->next;
-        }
-      intern->next->next = NULL;
-      intern->next->val = malloc (invallen + 1);
-      if (intern->next->val == NULL)
-       return YP_FALSE;
-      strncpy (intern->next->val, inval, invallen);
-      intern->next->val[invallen] = '\0';
+       intern->next->next = newp;
+      intern->next = newp;
+
+      newp->next = NULL;
+      *((char *) mempcpy (newp->val, inval, invallen)) = '\0';
     }
 
   return 0;
@@ -209,8 +202,6 @@ _nss_nis_initgroups_dyn (const char *user, gid_t group, long int *start,
 done:
   while (intern.start != NULL)
     {
-      if (intern.start->val != NULL)
-        free (intern.start->val);
       intern.next = intern.start;
       intern.start = intern.start->next;
       free (intern.next);
index b8c234ed6ffe0f59e059de2222d5ba8db53d6740..7c1ce320741745ec799b37aa5a3fbb9f34c7dea1 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-1998, 2000-2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1998, 2000-2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
 
@@ -37,8 +37,8 @@ __libc_lock_define_initialized (static, lock)
 
 struct response
 {
-  char *val;
   struct response *next;
+  char val[0];
 };
 
 static struct response *start;
@@ -53,26 +53,18 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval,
 
   if (inkey && inkeylen > 0 && inval && invallen > 0)
     {
+      struct response *newp = malloc (sizeof (struct response) + invallen + 1);
+      if (newp == NULL)
+       return YP_FALSE; /* We have no error code for out of memory */
+
       if (start == NULL)
-        {
-          start = malloc (sizeof (struct response));
-         if (start == NULL)
-           return YP_FALSE;
-          next = start;
-        }
+       start = newp;
       else
-        {
-          next->next = malloc (sizeof (struct response));
-         if (next->next == NULL)
-           return YP_FALSE;
-          next = next->next;
-        }
-      next->next = NULL;
-      next->val = malloc (invallen + 1);
-      if (next->val == NULL)
-       return YP_FALSE;
-      strncpy (next->val, inval, invallen);
-      next->val[invallen] = '\0';
+       next->next = newp;
+      next = newp;
+
+      newp->next = NULL;
+      *((char *) mempcpy (newp->val, inval, invallen)) = '\0';
     }
 
   return 0;
@@ -83,8 +75,6 @@ internal_nis_endprotoent (void)
 {
   while (start != NULL)
     {
-      if (start->val != NULL)
-        free (start->val);
       next = start;
       start = start->next;
       free (next);
index 6e707b9d58cd28afe403cc683940c8922d5d30fb..e4a39542c57595259158dc5d1028a3c1ddedbe2a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-1998, 2000, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1998,2000,2002,2003,2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
 
@@ -37,8 +37,8 @@ __libc_lock_define_initialized (static, lock)
 
 struct response_t
 {
-  char *val;
   struct response_t *next;
+  char val[0];
 };
 
 struct intern_t
@@ -61,26 +61,19 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval,
 
   if (inkey && inkeylen > 0 && inval && invallen > 0)
     {
+      struct response_t *newp = malloc (sizeof (struct response_t)
+                                       + invallen + 1);
+      if (newp == NULL)
+       return YP_FALSE; /* We have no error code for out of memory */
+
       if (intern->start == NULL)
-        {
-          intern->start = malloc (sizeof (struct response_t));
-         if (intern->start == NULL)
-           return YP_FALSE;
-          intern->next = intern->start;
-        }
+       intern->start = newp;
       else
-        {
-          intern->next->next = malloc (sizeof (struct response_t));
-         if (intern->next->next == NULL)
-           return YP_FALSE;
-          intern->next = intern->next->next;
-        }
-      intern->next->next = NULL;
-      intern->next->val = malloc (invallen + 1);
-      if (intern->next->val == NULL)
-       return YP_FALSE;
-      strncpy (intern->next->val, inval, invallen);
-      intern->next->val[invallen] = '\0';
+       intern->next->next = newp;
+      intern->next = newp;
+
+      newp->next = NULL;
+      *((char *) mempcpy (newp->val, inval, invallen)) = '\0';
     }
 
   return 0;
@@ -91,8 +84,6 @@ internal_nis_endrpcent (intern_t *intern)
 {
   while (intern->start != NULL)
     {
-      if (intern->start->val != NULL)
-        free (intern->start->val);
       intern->next = intern->start;
       intern->start = intern->start->next;
       free (intern->next);
index c25422f3ca96be9503798a78ee5343de05b07d25..9af9fd20a34db36dd3354914427cde82166c6752 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2001, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2001, 2002, 2003, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
 
@@ -38,8 +38,8 @@ __libc_lock_define_initialized (static, lock)
 
 struct response_t
 {
-  char *val;
   struct response_t *next;
+  char val[0];
 };
 
 struct intern_t
@@ -62,26 +62,19 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval,
 
   if (inkey && inkeylen > 0 && inval && invallen > 0)
     {
+      struct response_t *newp = malloc (sizeof (struct response_t)
+                                       + invallen + 1);
+      if (newp == NULL)
+       return YP_FALSE; /* We have no error code for out of memory */
+
       if (intern->start == NULL)
-        {
-          intern->start = malloc (sizeof (struct response_t));
-         if (intern->start == NULL)
-           return YP_FALSE; /* We have no error code for out of memory */
-          intern->next = intern->start;
-        }
+       intern->start = newp;
       else
-        {
-          intern->next->next = malloc (sizeof (struct response_t));
-         if (intern->next->next == NULL)
-           return YP_FALSE; /* We have no error code for out of memory */
-          intern->next = intern->next->next;
-        }
-      intern->next->next = NULL;
-      intern->next->val = malloc (invallen + 1);
-      if (intern->next->val == NULL)
-       return YP_FALSE; /* We have no error code for out of memory */
-      strncpy (intern->next->val, inval, invallen);
-      intern->next->val[invallen] = '\0';
+       intern->next->next = newp;
+      intern->next = newp;
+
+      newp->next = NULL;
+      *((char *) mempcpy (newp->val, inval, invallen)) = '\0';
     }
 
   return 0;
@@ -92,13 +85,10 @@ internal_nis_endservent (intern_t * intern)
 {
   while (intern->start != NULL)
     {
-      if (intern->start->val != NULL)
-        free (intern->start->val);
       intern->next = intern->start;
       intern->start = intern->start->next;
       free (intern->next);
     }
-  intern->start = NULL;
 
   return NSS_STATUS_SUCCESS;
 }