This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

intl patches (32)



A patch to 1. compact looping code, 2. make the loop worst-case runtime
and stack-space usage be O(n) instead of O(n^2).


2001-03-04  Bruno Haible  <bruno@clisp.org>

	* intl/dcigettext.c (DCIGETTEXT): Increment path_max proportionally.

--- glibc-20011110/intl/dcigettext.c.bak	Thu Nov 22 02:00:35 2001
+++ glibc-20011110/intl/dcigettext.c	Thu Nov 22 01:12:10 2001
@@ -448,16 +460,18 @@
       path_max = (unsigned int) PATH_MAX;
       path_max += 2;		/* The getcwd docs say to do this.  */
 
-      dirname = (char *) alloca (path_max + dirname_len);
-      ADD_BLOCK (block_list, dirname);
-
-      __set_errno (0);
-      while ((ret = getcwd (dirname, path_max)) == NULL && errno == ERANGE)
+      for (;;)
 	{
-	  path_max += PATH_INCR;
 	  dirname = (char *) alloca (path_max + dirname_len);
 	  ADD_BLOCK (block_list, dirname);
+
 	  __set_errno (0);
+	  ret = getcwd (dirname, path_max);
+	  if (ret != NULL || errno != ERANGE)
+	    break;
+
+	  path_max += path_max / 2;
+	  path_max += PATH_INCR;
 	}
 
       if (ret == NULL)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]