comparison src/filelock.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 e38acbeb1cae
children 1d8fb2eee1bb
comparison
equal deleted inserted replaced
850:f915ad7befaf 851:e7ee5f8bde58
91 #define FREE_LOCK_INFO(i) do { xfree ((i).user); xfree ((i).host); } while (0) 91 #define FREE_LOCK_INFO(i) do { xfree ((i).user); xfree ((i).host); } while (0)
92 92
93 /* Write the name of the lock file for FN into LFNAME. Length will be 93 /* Write the name of the lock file for FN into LFNAME. Length will be
94 that of FN plus two more for the leading `.#' plus one for the null. */ 94 that of FN plus two more for the leading `.#' plus one for the null. */
95 #define MAKE_LOCK_NAME(lock, file) \ 95 #define MAKE_LOCK_NAME(lock, file) \
96 (lock = (Intbyte *) alloca (XSTRING_LENGTH (file) + 2 + 1), \ 96 (lock = (Intbyte *) ALLOCA (XSTRING_LENGTH (file) + 2 + 1), \
97 fill_in_lock_file_name (lock, file)) 97 fill_in_lock_file_name (lock, file))
98 98
99 static void 99 static void
100 fill_in_lock_file_name (Intbyte *lockfile, Lisp_Object fn) 100 fill_in_lock_file_name (Intbyte *lockfile, Lisp_Object fn)
101 { 101 {
136 host_name = XSTRING_DATA (Vsystem_name); 136 host_name = XSTRING_DATA (Vsystem_name);
137 else 137 else
138 host_name = (Intbyte *) ""; 138 host_name = (Intbyte *) "";
139 139
140 lock_info_str = 140 lock_info_str =
141 (Intbyte *) alloca (qxestrlen (user_name) + qxestrlen (host_name) 141 (Intbyte *) ALLOCA (qxestrlen (user_name) + qxestrlen (host_name)
142 + LOCK_PID_MAX + 5); 142 + LOCK_PID_MAX + 5);
143 143
144 qxesprintf (lock_info_str, "%s@%s.%d", user_name, host_name, qxe_getpid ()); 144 qxesprintf (lock_info_str, "%s@%s.%d", user_name, host_name, qxe_getpid ());
145 145
146 err = qxe_symlink (lock_info_str, lfname); 146 err = qxe_symlink (lock_info_str, lfname);
189 189
190 /* Even if the caller doesn't want the owner info, we still have to 190 /* Even if the caller doesn't want the owner info, we still have to
191 read it to determine return value, so allocate it. */ 191 read it to determine return value, so allocate it. */
192 if (!owner) 192 if (!owner)
193 { 193 {
194 owner = (lock_info_type *) alloca (sizeof (lock_info_type)); 194 owner = (lock_info_type *) ALLOCA (sizeof (lock_info_type));
195 local_owner = 1; 195 local_owner = 1;
196 } 196 }
197 197
198 /* Parse USER@HOST.PID. If can't parse, return -1. */ 198 /* Parse USER@HOST.PID. If can't parse, return -1. */
199 /* The USER is everything before the first @. */ 199 /* The USER is everything before the first @. */
344 /* Return now if we have locked it, or if lock creation failed 344 /* Return now if we have locked it, or if lock creation failed
345 or current buffer is killed. */ 345 or current buffer is killed. */
346 goto done; 346 goto done;
347 347
348 /* Else consider breaking the lock */ 348 /* Else consider breaking the lock */
349 locker = (Intbyte *) alloca (qxestrlen (lock_info.user) 349 locker = (Intbyte *) ALLOCA (qxestrlen (lock_info.user)
350 + qxestrlen (lock_info.host) 350 + qxestrlen (lock_info.host)
351 + LOCK_PID_MAX + 9); 351 + LOCK_PID_MAX + 9);
352 qxesprintf (locker, "%s@%s (pid %d)", lock_info.user, lock_info.host, 352 qxesprintf (locker, "%s@%s (pid %d)", lock_info.user, lock_info.host,
353 lock_info.pid); 353 lock_info.pid);
354 FREE_LOCK_INFO (lock_info); 354 FREE_LOCK_INFO (lock_info);