diff options
author | Thomas G. Lane <tgl@netcom.com> | 1992-03-17 00:00:00 +0000 |
---|---|---|
committer | DRC <information@libjpeg-turbo.org> | 2015-07-29 15:21:19 -0500 |
commit | 4a6b7303643714d495b9d26742d8a156fd120936 (patch) | |
tree | 5997fe7ad49b32b2adc4eeabae49f839ab73f9a5 /jerror.c | |
parent | bd543f030e7e435c2c6a6a7d52ad927ae97cd927 (diff) |
The Independent JPEG Group's JPEG software v3
Diffstat (limited to 'jerror.c')
-rw-r--r-- | jerror.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -1,7 +1,7 @@ /* * jerror.c * - * Copyright (C) 1991, Thomas G. Lane. + * Copyright (C) 1991, 1992, Thomas G. Lane. * This file is part of the Independent JPEG Group's software. * For conditions of distribution and use, see the accompanying README file. * @@ -13,9 +13,9 @@ * The error_exit() routine should not return to its caller. Within a * larger application, you might want to have it do a longjmp() to return * control to the outer user interface routine. This should work since - * the portable JPEG code doesn't use setjmp/longjmp. However, this won't - * release allocated memory or close temp files --- some bookkeeping would - * need to be added to the memory manager module to make that work. + * the portable JPEG code doesn't use setjmp/longjmp. You should make sure + * that free_all is called either within error_exit or after the return to + * the outer-level routine. * * These routines are used by both the compression and decompression code. */ @@ -25,8 +25,12 @@ #include <stdlib.h> /* to declare exit() */ #endif +#ifndef EXIT_FAILURE /* define exit() codes if not provided */ +#define EXIT_FAILURE 1 +#endif + -static external_methods_ptr methods; /* saved for access to message_parm */ +static external_methods_ptr methods; /* saved for access to message_parm, free_all */ METHODDEF void @@ -45,7 +49,8 @@ METHODDEF void error_exit (const char *msgtext) { trace_message(msgtext); - exit(1); + (*methods->free_all) (); /* clean up memory allocation */ + exit(EXIT_FAILURE); } @@ -58,7 +63,7 @@ error_exit (const char *msgtext) GLOBAL void jselerror (external_methods_ptr emethods) { - methods = emethods; /* save struct addr for msg parm access */ + methods = emethods; /* save struct addr for later access */ emethods->error_exit = error_exit; emethods->trace_message = trace_message; |