about summary refs log tree commit diff
path: root/nis/nss_nis/nis-grp.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-04-29 01:14:07 +0000
committerUlrich Drepper <drepper@redhat.com>2006-04-29 01:14:07 +0000
commite0d4e91d2b0e8069fc044899cf04a41db3612ffb (patch)
tree6a3f542af192521f75572d7f2cf239ed68478288 /nis/nss_nis/nis-grp.c
parent4eaa9bb48b319803544909a085651fc6ff4a9ea1 (diff)
downloadglibc-e0d4e91d2b0e8069fc044899cf04a41db3612ffb.tar.gz
glibc-e0d4e91d2b0e8069fc044899cf04a41db3612ffb.tar.xz
glibc-e0d4e91d2b0e8069fc044899cf04a41db3612ffb.zip
* nis/nss_nis/nis-spwd.c (internal_nis_getspent_r): Remove data
	variable.

	* nis/nss-nis.h: Define response_t and intern_t.  Declare _nis_saveit.
	* nis/nss_nis/nis-pwd.c: Remove response_t and intern_t definition.
	(saveit): Renamed to _nis_saveit.  Take parameter which is pointer
	to the intern_t object.  Change all users.
	* nis/nss_nis/nis-grp.c: Remove response_t, intern_t, and saveit
	definition.  Use _nis_saveit instead of saveit.
	* nis/nss_nis/nis-service.c: Likewise.
	* nis/nss_nis/nis-initgroups.c: Likewise.
	(internal_setgrent): Adjust for buffer handling.
	(internal_getgrent_r): Likewise.
	* nis/nss_nis/nis-rpc.c: Likewise.
Diffstat (limited to 'nis/nss_nis/nis-grp.c')
-rw-r--r--nis/nss_nis/nis-grp.c77
1 files changed, 2 insertions, 75 deletions
diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c
index 10af019492..ce642c484f 100644
--- a/nis/nss_nis/nis-grp.c
+++ b/nis/nss_nis/nis-grp.c
@@ -41,82 +41,9 @@ __libc_lock_define_initialized (static, lock)
 static bool_t new_start = 1;
 static char *oldkey;
 static int oldkeylen;
-
-struct response_t
-{
-  struct response_t *next;
-  size_t size;
-  char mem[0];
-};
-
-typedef struct intern_t
-{
-  struct response_t *start;
-  struct response_t *next;
-  size_t offset;
-} intern_t;
-
 static intern_t intern;
 
 
-static int
-saveit (int instatus, char *inkey, int inkeylen, char *inval,
-        int invallen, char *indata)
-{
-  if (instatus != YP_TRUE)
-    return 1;
-
-  if (inkey && inkeylen > 0 && inval && invallen > 0)
-    {
-      struct response_t *bucket = intern.next;
-
-      if (__builtin_expect (bucket == NULL, 0))
-	{
-#define MINSIZE 4096 - 4 * sizeof (void *)
-	  const size_t minsize = MAX (MINSIZE, 2 * (invallen + 1));
-	  bucket = malloc (sizeof (struct response_t) + minsize);
-	  if (bucket == NULL)
-	    /* We have no error code for out of memory.  */
-	    return 1;
-
-	  bucket->next = NULL;
-	  bucket->size = minsize;
-	  intern.start = intern.next = bucket;
-	  intern.offset = 0;
-	}
-      else if (__builtin_expect (invallen + 1 > bucket->size - intern.offset,
-				 0))
-	{
-	  /* We need a new (larger) buffer.  */
-	  const size_t newsize = 2 * MAX (bucket->size, invallen + 1);
-	  struct response_t *newp = malloc (sizeof (struct response_t)
-					    + newsize);
-	  if (newp == NULL)
-	    /* We have no error code for out of memory.  */
-	    return 1;
-
-	  /* Mark the old bucket as full.  */
-	  bucket->size = intern.offset;
-
-	  newp->next = NULL;
-	  newp->size = newsize;
-	  bucket = intern.next = bucket->next = newp;
-	  intern.offset = 0;
-	}
-
-      char *p = mempcpy (&bucket->mem[intern.offset], inval, invallen);
-      if (__builtin_expect (p[-1] != '\0', 0))
-	{
-	  *p = '\0';
-	  ++invallen;
-	}
-      intern.offset += invallen;
-    }
-
-  return 0;
-}
-
-
 static void
 internal_nis_endgrent (void)
 {
@@ -164,8 +91,8 @@ internal_nis_setgrent (void)
 
   struct ypall_callback ypcb;
 
-  ypcb.foreach = saveit;
-  ypcb.data = NULL;
+  ypcb.foreach = _nis_saveit;
+  ypcb.data = (char *) &intern;
   enum nss_status status = yperr2nss (yp_all (domain, "group.byname", &ypcb));