aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTom Tromey2013-07-04 20:02:20 -0600
committerTom Tromey2013-07-04 20:02:20 -0600
commit3bf8db999bd8857a1f8ae10dafe09182f68be58f (patch)
treefd8ec3bbee65626c1cc3c5ca911834ae44f6a6a6 /src
parent9db4b98e1356549d999b342bd449f916c27fea8a (diff)
downloademacs-3bf8db999bd8857a1f8ae10dafe09182f68be58f.tar.gz
emacs-3bf8db999bd8857a1f8ae10dafe09182f68be58f.zip
avoid SAFE_ALLOCA
avoid SAFE_ALLOCA in xgselect.c. in this code it is just as easy to always use malloc; and it avoids thread-switching problems, as the safe-alloca stuff implicitly refers to the current thread
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 {