aboutsummaryrefslogtreecommitdiffstats
path: root/src/eval.c
diff options
context:
space:
mode:
authorPaul Eggert2013-07-17 19:12:59 -0700
committerPaul Eggert2013-07-17 19:12:59 -0700
commitf4b1eb36186a2f873d84d4c089292f9fb0394d31 (patch)
treeea6a4d904679b9f50026abb6dfab00f9b693eb6a /src/eval.c
parenta0931322f6c257bb4a4a678f62dcb4ae3b253221 (diff)
downloademacs-f4b1eb36186a2f873d84d4c089292f9fb0394d31.tar.gz
emacs-f4b1eb36186a2f873d84d4c089292f9fb0394d31.zip
* charset.c: Fix file descriptor leaks and errno issues.
Include <errno.h>. (load_charset_map_from_file): Don't leak file descriptor on error. Use plain record_xmalloc since the allocation is larger than MAX_ALLOCA; that's simpler here. Simplify test for exhaustion of entries. * eval.c (record_unwind_protect_nothing): * fileio.c (fclose_unwind): New functions. * lread.c (load_unwind): Remove. All uses replaced by fclose_unwind. The replacement doesn't block input, but that no longer seems necessary.
Diffstat (limited to 'src/eval.c')
-rw-r--r--src/eval.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/eval.c b/src/eval.c
index a4f94ee1415..23834cb54f6 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -3190,6 +3190,8 @@ specbind (Lisp_Object symbol, Lisp_Object value)
3190 } 3190 }
3191} 3191}
3192 3192
3193/* Push unwind-protect entries of various types. */
3194
3193void 3195void
3194record_unwind_protect (void (*function) (Lisp_Object), Lisp_Object arg) 3196record_unwind_protect (void (*function) (Lisp_Object), Lisp_Object arg)
3195{ 3197{
@@ -3229,6 +3231,18 @@ static void
3229do_nothing (void) 3231do_nothing (void)
3230{} 3232{}
3231 3233
3234/* Push an unwind-protect entry that does nothing, so that
3235 set_unwind_protect_ptr can overwrite it later. */
3236
3237void
3238record_unwind_protect_nothing (void)
3239{
3240 record_unwind_protect_void (do_nothing);
3241}
3242
3243/* Clear the unwind-protect entry COUNT, so that it does nothing.
3244 It need not be at the top of the stack. */
3245
3232void 3246void
3233clear_unwind_protect (ptrdiff_t count) 3247clear_unwind_protect (ptrdiff_t count)
3234{ 3248{
@@ -3237,6 +3251,10 @@ clear_unwind_protect (ptrdiff_t count)
3237 p->unwind_void.func = do_nothing; 3251 p->unwind_void.func = do_nothing;
3238} 3252}
3239 3253
3254/* Set the unwind-protect entry COUNT so that it invokes FUNC (ARG).
3255 It need not be at the top of the stack. Discard the entry's
3256 previous value without invoking it. */
3257
3240void 3258void
3241set_unwind_protect_ptr (ptrdiff_t count, void (*func) (void *), void *arg) 3259set_unwind_protect_ptr (ptrdiff_t count, void (*func) (void *), void *arg)
3242{ 3260{
@@ -3246,6 +3264,9 @@ set_unwind_protect_ptr (ptrdiff_t count, void (*func) (void *), void *arg)
3246 p->unwind_ptr.arg = arg; 3264 p->unwind_ptr.arg = arg;
3247} 3265}
3248 3266
3267/* Pop and execute entries from the unwind-protect stack until the
3268 depth COUNT is reached. Return VALUE. */
3269
3249Lisp_Object 3270Lisp_Object
3250unbind_to (ptrdiff_t count, Lisp_Object value) 3271unbind_to (ptrdiff_t count, Lisp_Object value)
3251{ 3272{