diff options
| author | Tom Tromey <tromey@redhat.com> | 2013-07-04 20:02:20 -0600 |
|---|---|---|
| committer | Tom Tromey <tromey@redhat.com> | 2013-07-04 20:02:20 -0600 |
| commit | 3bf8db999bd8857a1f8ae10dafe09182f68be58f (patch) | |
| tree | fd8ec3bbee65626c1cc3c5ca911834ae44f6a6a6 | |
| parent | 9db4b98e1356549d999b342bd449f916c27fea8a (diff) | |
| download | emacs-3bf8db999bd8857a1f8ae10dafe09182f68be58f.tar.gz | |
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
| -rw-r--r-- | src/xgselect.c | 9 |
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, GPollFD *gfds = gfds_buf; int gfds_size = sizeof gfds_buf / sizeof *gfds_buf; int n_gfds, retval = 0, our_fds = 0, max_fds = fds_lim - 1; - int i, nfds, tmo_in_millisec; - USE_SAFE_ALLOCA; + int i, nfds, tmo_in_millisec, must_free = 0; /* Do not try to optimize with an initial check with g_main_context_pending 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, gfds, gfds_size); if (gfds_size < n_gfds) { - SAFE_NALLOCA (gfds, sizeof *gfds, n_gfds); + gfds = xnmalloc (n_gfds, sizeof *gfds); + must_free = 1; gfds_size = n_gfds; n_gfds = g_main_context_query (context, G_PRIORITY_LOW, &tmo_in_millisec, gfds, gfds_size); @@ -81,7 +81,8 @@ xg_select (int fds_lim, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, } } - SAFE_FREE (); + if (must_free) + xfree (gfds); if (tmo_in_millisec >= 0) { |
