aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xgselect.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/xgselect.c b/src/xgselect.c
index 4d90298a9d9..15ee59dfa81 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -40,8 +40,7 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
40 GPollFD *gfds = gfds_buf; 40 GPollFD *gfds = gfds_buf;
41 int gfds_size = sizeof gfds_buf / sizeof *gfds_buf; 41 int gfds_size = sizeof gfds_buf / sizeof *gfds_buf;
42 int n_gfds, retval = 0, our_fds = 0, max_fds = fds_lim - 1; 42 int n_gfds, retval = 0, our_fds = 0, max_fds = fds_lim - 1;
43 int i, nfds, tmo_in_millisec; 43 int i, nfds, tmo_in_millisec, must_free = 0;
44 USE_SAFE_ALLOCA;
45 44
46 /* Do not try to optimize with an initial check with g_main_context_pending 45 /* Do not try to optimize with an initial check with g_main_context_pending
47 and a call to pselect if it returns false. If Gdk has a timeout for 0.01 46 and a call to pselect if it returns false. If Gdk has a timeout for 0.01
@@ -60,7 +59,8 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
60 gfds, gfds_size); 59 gfds, gfds_size);
61 if (gfds_size < n_gfds) 60 if (gfds_size < n_gfds)
62 { 61 {
63 SAFE_NALLOCA (gfds, sizeof *gfds, n_gfds); 62 gfds = xnmalloc (n_gfds, sizeof *gfds);
63 must_free = 1;
64 gfds_size = n_gfds; 64 gfds_size = n_gfds;
65 n_gfds = g_main_context_query (context, G_PRIORITY_LOW, &tmo_in_millisec, 65 n_gfds = g_main_context_query (context, G_PRIORITY_LOW, &tmo_in_millisec,
66 gfds, gfds_size); 66 gfds, gfds_size);
@@ -81,7 +81,8 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds,
81 } 81 }
82 } 82 }
83 83
84 SAFE_FREE (); 84 if (must_free)
85 xfree (gfds);
85 86
86 if (tmo_in_millisec >= 0) 87 if (tmo_in_millisec >= 0)
87 { 88 {