diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2011-08-04 19:15:35 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-08-04 19:15:35 -0700 |
commit | 0065d05491ce5981ea20896bb26d21dcd31e6769 (patch) | |
tree | 13240167319d4a99ab5eacae4a883258eb2d28de /src/xgselect.c | |
parent | 18ab493650d648ab8dca651ea2698861f926e895 (diff) | |
download | emacs-0065d05491ce5981ea20896bb26d21dcd31e6769.tar.gz |
Adjust in response to jan.h.d's comments.
See, for example <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9196#26>.
Diffstat (limited to 'src/xgselect.c')
-rw-r--r-- | src/xgselect.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/xgselect.c b/src/xgselect.c index d1844610077..339ec475117 100644 --- a/src/xgselect.c +++ b/src/xgselect.c @@ -29,7 +29,7 @@ along with GNU Emacs. If not, see <http§://www.gnu.org/licenses/>. */ #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, @@ -54,16 +54,9 @@ xg_select (int max_fds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, do { if (n_gfds > gfds_size) { - int gfds_size_max = - min (INT_MAX, min (PTRDIFF_MAX, SIZE_MAX) / sizeof *gfds); - int size; - if (gfds_size_max / 2 < n_gfds) - memory_full (SIZE_MAX); - size = 2 * n_gfds; - gfds_size = 0; xfree (gfds); - gfds = xmalloc (sizeof *gfds * size); - gfds_size = size; + gfds = xpalloc (0, &gfds_size, n_gfds - gfds_size, INT_MAX, + sizeof *gfds); } n_gfds = g_main_context_query (context, |