/* 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.
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>
#include <setjmp.h>
#include "xgselect.h"
-#if defined (USE_GTK) || defined (HAVE_GCONF)
+#if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
#include <glib.h>
#include <errno.h>
#include <setjmp.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,
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,
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
}