]> code.delx.au - gnu-emacs/blobdiff - src/xgselect.c
Make GC_MAKE_GCPROS_NOOPS the default (Bug#9926).
[gnu-emacs] / src / xgselect.c
index 96d763ff088436fd861e6fddf32be39c1a3f0b17..80dbfc32aee86726337115c686e4dcb1664bf1bd 100644 (file)
@@ -1,6 +1,6 @@
 /* Function for handling the GLib event loop.
 
-Copyright (C) 2009-2011  Free Software Foundation, Inc.
+Copyright (C) 2009-2012  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -15,18 +15,21 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
+along with GNU Emacs.  If not, see <httpยง://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 
-#if defined (USE_GTK) || defined (HAVE_GCONF)
+#include <setjmp.h>
+#include "xgselect.h"
+
+#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
+
 #include <glib.h>
 #include <errno.h>
 #include <setjmp.h>
-#include "xgselect.h"
 
 static GPollFD *gfds;
-static int gfds_size;
+static ptrdiff_t gfds_size;
 
 int
 xg_select (int max_fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
@@ -51,10 +54,9 @@ xg_select (int max_fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
   do {
     if (n_gfds > gfds_size)
       {
-        while (n_gfds > gfds_size)
-          gfds_size *= 2;
         xfree (gfds);
-        gfds = xmalloc (sizeof (*gfds) * gfds_size);
+       gfds = xpalloc (0, &gfds_size, n_gfds - gfds_size, INT_MAX,
+                       sizeof *gfds);
       }
 
     n_gfds = g_main_context_query (context,
@@ -146,13 +148,13 @@ xg_select (int max_fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
 
   return retval;
 }
-#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
+#endif /* USE_GTK || HAVE_GCONF || HAVE_GSETTINGS */
 
 void
 xgselect_initialize (void)
 {
-#if defined (USE_GTK) || defined (HAVE_GCONF)
+#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
   gfds_size = 128;
   gfds = xmalloc (sizeof (*gfds)*gfds_size);
-#endif /* defined (USE_GTK) || defined (HAVE_GCONF) */
+#endif
 }