comparison src/sysdep.c @ 851:e7ee5f8bde58

[xemacs-hg @ 2002-05-23 11:46:08 by ben] fix for raymond toy's crash, alloca crashes, some recover-session improvements files.el: Recover-session improvements: Only show session files where some files can actually be recovered, and show in chronological order. subr.el, menubar-items.el: As promised to rms, the functionality in truncate-string-with-continuation-dots has been merged into truncate-string-to-width. Change callers in menubar-items.el. select.el: Document some of these funs better. Fix problem where we were doing own-clipboard twice. Makefile.in.in: Add alloca.o. Ensure that alloca.s doesn't compile into alloca.o, but allocax.o (not that it's currently used or anything.) EmacsFrame.c, abbrev.c, alloc.c, alloca.c, callint.c, callproc.c, config.h.in, device-msw.c, device-x.c, dired.c, doc.c, editfns.c, emacs.c, emodules.c, eval.c, event-Xt.c, event-msw.c, event-stream.c, file-coding.c, fileio.c, filelock.c, fns.c, glyphs-gtk.c, glyphs-msw.c, glyphs-x.c, gui-x.c, input-method-xlib.c, intl-win32.c, lisp.h, lread.c, menubar-gtk.c, menubar-msw.c, menubar.c, mule-wnnfns.c, nt.c, objects-msw.c, process-nt.c, realpath.c, redisplay-gtk.c, redisplay-output.c, redisplay-x.c, redisplay.c, search.c, select-msw.c, sysdep.c, syswindows.h, text.c, text.h, ui-byhand.c: Fix Raymond Toy's crash. Repeat to self: 2^21 - 1 is NOT the same as (2 << 21) - 1. Fix crashes due to excessive alloca(). replace alloca() with ALLOCA(), which calls the C alloca() [which uses xmalloc()] when the size is too big. Insert in various places calls to try to flush the C alloca() stored info if there is any. Add MALLOC_OR_ALLOCA(), for places that expect to be alloca()ing large blocks. This xmalloc()s when too large and records an unwind-protect to free -- relying on the caller to unbind_to() elsewhere in the function. Use it in concat(). Use MALLOC instead of ALLOCA in select-msw.c. xemacs.mak: Add alloca.o.
author ben
date Thu, 23 May 2002 11:46:46 +0000
parents 39d30f8fadfd
children 2b6fa2618f76
comparison
equal deleted inserted replaced
850:f915ad7befaf 851:e7ee5f8bde58
587 results, so put the slash back. */ 587 results, so put the slash back. */
588 dir = Ffile_name_as_directory (dir); 588 dir = Ffile_name_as_directory (dir);
589 dir = Funhandled_file_name_directory (dir); 589 dir = Funhandled_file_name_directory (dir);
590 dir = expand_and_dir_to_file (dir, Qnil); 590 dir = expand_and_dir_to_file (dir, Qnil);
591 591
592 str = (Intbyte *) alloca (XSTRING_LENGTH (dir) + 2); 592 str = (Intbyte *) ALLOCA (XSTRING_LENGTH (dir) + 2);
593 len = XSTRING_LENGTH (dir); 593 len = XSTRING_LENGTH (dir);
594 memcpy (str, XSTRING_DATA (dir), len); 594 memcpy (str, XSTRING_DATA (dir), len);
595 if (!IS_ANY_SEP (str[len - 1])) 595 if (!IS_ANY_SEP (str[len - 1]))
596 str[len++] = DIRECTORY_SEP; 596 str[len++] = DIRECTORY_SEP;
597 str[len] = 0; 597 str[len] = 0;
2234 struct utsname uts; 2234 struct utsname uts;
2235 uname (&uts); 2235 uname (&uts);
2236 Vsystem_name = build_string (uts.nodename); 2236 Vsystem_name = build_string (uts.nodename);
2237 #else /* HAVE_GETHOSTNAME */ 2237 #else /* HAVE_GETHOSTNAME */
2238 int hostname_size = 256; 2238 int hostname_size = 256;
2239 char *hostname = (char *) alloca (hostname_size); 2239 char *hostname = (char *) ALLOCA (hostname_size);
2240 2240
2241 /* Try to get the host name; if the buffer is too short, try 2241 /* Try to get the host name; if the buffer is too short, try
2242 again. Apparently, the only indication gethostname gives of 2242 again. Apparently, the only indication gethostname gives of
2243 whether the buffer was large enough is the presence or absence 2243 whether the buffer was large enough is the presence or absence
2244 of a '\0' in the string. Eech. */ 2244 of a '\0' in the string. Eech. */
2250 /* Was the buffer large enough for the '\0'? */ 2250 /* Was the buffer large enough for the '\0'? */
2251 if ((int) strlen (hostname) < (hostname_size - 1)) 2251 if ((int) strlen (hostname) < (hostname_size - 1))
2252 break; 2252 break;
2253 2253
2254 hostname_size <<= 1; 2254 hostname_size <<= 1;
2255 hostname = (char *) alloca (hostname_size); 2255 hostname = (char *) ALLOCA (hostname_size);
2256 } 2256 }
2257 # if defined( HAVE_SOCKETS) 2257 # if defined( HAVE_SOCKETS)
2258 /* Turn the hostname into the official, fully-qualified hostname. 2258 /* Turn the hostname into the official, fully-qualified hostname.
2259 Don't do this if we're going to dump; this can confuse system 2259 Don't do this if we're going to dump; this can confuse system
2260 libraries on some machines and make the dumped emacs core dump. */ 2260 libraries on some machines and make the dumped emacs core dump. */
2293 while (*alias && !strchr (*alias, '.')) 2293 while (*alias && !strchr (*alias, '.'))
2294 alias++; 2294 alias++;
2295 if (*alias) 2295 if (*alias)
2296 fqdn = *alias; 2296 fqdn = *alias;
2297 } 2297 }
2298 hostname = (char *) alloca (strlen (fqdn) + 1); 2298 hostname = (char *) ALLOCA (strlen (fqdn) + 1);
2299 strcpy (hostname, fqdn); 2299 strcpy (hostname, fqdn);
2300 } 2300 }
2301 # else /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */ 2301 # else /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */
2302 struct addrinfo hints, *res; 2302 struct addrinfo hints, *res;
2303 2303
2310 #endif 2310 #endif
2311 hints.ai_socktype = SOCK_STREAM; 2311 hints.ai_socktype = SOCK_STREAM;
2312 hints.ai_protocol = 0; 2312 hints.ai_protocol = 0;
2313 if (!getaddrinfo (hostname, NULL, &hints, &res)) 2313 if (!getaddrinfo (hostname, NULL, &hints, &res))
2314 { 2314 {
2315 hostname = (char *) alloca (strlen (res->ai_canonname) + 1); 2315 hostname = (char *) ALLOCA (strlen (res->ai_canonname) + 1);
2316 strcpy (hostname, res->ai_canonname); 2316 strcpy (hostname, res->ai_canonname);
2317 2317
2318 freeaddrinfo (res); 2318 freeaddrinfo (res);
2319 } 2319 }
2320 # endif /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */ 2320 # endif /* !(HAVE_GETADDRINFO && HAVE_GETNAMEINFO) */