diff options
| author | Paul Eggert | 2013-07-17 19:12:59 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-07-17 19:12:59 -0700 |
| commit | f4b1eb36186a2f873d84d4c089292f9fb0394d31 (patch) | |
| tree | ea6a4d904679b9f50026abb6dfab00f9b693eb6a /src/eval.c | |
| parent | a0931322f6c257bb4a4a678f62dcb4ae3b253221 (diff) | |
| download | emacs-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.c | 21 |
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 | |||
| 3193 | void | 3195 | void |
| 3194 | record_unwind_protect (void (*function) (Lisp_Object), Lisp_Object arg) | 3196 | record_unwind_protect (void (*function) (Lisp_Object), Lisp_Object arg) |
| 3195 | { | 3197 | { |
| @@ -3229,6 +3231,18 @@ static void | |||
| 3229 | do_nothing (void) | 3231 | do_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 | |||
| 3237 | void | ||
| 3238 | record_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 | |||
| 3232 | void | 3246 | void |
| 3233 | clear_unwind_protect (ptrdiff_t count) | 3247 | clear_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 | |||
| 3240 | void | 3258 | void |
| 3241 | set_unwind_protect_ptr (ptrdiff_t count, void (*func) (void *), void *arg) | 3259 | set_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 | |||
| 3249 | Lisp_Object | 3270 | Lisp_Object |
| 3250 | unbind_to (ptrdiff_t count, Lisp_Object value) | 3271 | unbind_to (ptrdiff_t count, Lisp_Object value) |
| 3251 | { | 3272 | { |