Subject: Update of patch

From: Maciej Marcin Piechotka <[email-masked]>
Date: Sat, 28 Jan 2012 18:46:51 +0000

Ups. Sorry - I forgot to add one file to git index. Corrected patch
attached.
>From 3a06fc2b48eb7e55834d8e5e4adda1f2286758db Mon Sep 17 00:00:00 2001
From: Maciej Piechotka <[email-masked]>
Date: Sat, 28 Jan 2012 16:12:45 +0000
Subject: [PATCH] Fix infinit loop when emacs is compiled with GTK+ support
 and used in no-window mode

---
 src/xgselect.c |   17 +++++------------
 src/xgselect.h |    2 --
 src/xterm.c    |    2 --
 3 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/src/xgselect.c b/src/xgselect.c
index 333f7b1..4301eee 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -55,9 +55,11 @@ xg_select (max_fds, rfds, wfds, efds, timeout)
   do {
     if (n_gfds > gfds_size) 
       {
-        while (n_gfds > gfds_size) 
-          gfds_size *= 2;
-        xfree (gfds);
+        gfds_size = 1 << g_bit_storage (n_gfds);
+        if (gfds)
+          {
+            xfree (gfds);
+          }
         gfds = xmalloc (sizeof (*gfds) * gfds_size);
       }
 
@@ -152,14 +154,5 @@ xg_select (max_fds, rfds, wfds, efds, timeout)
 }
 #endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
 
-void
-xgselect_initialize ()
-{
-#if defined (USE_GTK) || defined (HAVE_GCONF)
-  gfds_size = 128;
-  gfds = xmalloc (sizeof (*gfds)*gfds_size);
-#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
-}
-
 /* arch-tag: c5873ee3-d1f6-44f9-9f3b-b14f70fd0e6a
    (do not change this comment) */
diff --git a/src/xgselect.h b/src/xgselect.h
index 14488d6..3bb5428 100644
--- a/src/xgselect.h
+++ b/src/xgselect.h
@@ -30,8 +30,6 @@ extern int xg_select P_ ((int max_fds,
                           SELECT_TYPE *efds,
                           EMACS_TIME *timeout));
 
-extern void xgselect_initialize P_ ((void));
-
 #endif /* XGSELECT_H */
 
 /* arch-tag: 0c5392a8-3a41-41eb-839c-58e6595926f0
diff --git a/src/xterm.c b/src/xterm.c
index af8af50..83412ae 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10989,8 +10989,6 @@ x_initialize ()
   XSetIOErrorHandler (x_io_error_quitter);
 
   signal (SIGPIPE, x_connection_signal);
-
-  xgselect_initialize ();
 }

-- 
1.7.8.4