aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lemon
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-06-12 12:18:14 -0700
committerGuy Harris <guy@alum.mit.edu>2016-06-12 19:18:41 +0000
commit38d39f292e01551fe30b57583bd79a0d06d59420 (patch)
treefe989a77f65cddfaad57e0aa78e7857d01df5380 /tools/lemon
parent7bbc60c668b69542ceaa6797ec1080425200f3b1 (diff)
Have MemoryCheck() directly incorporate the error message and exit.
Manually inline memory_error() in MemoryCheck(), so that static analyzers know that, if MemoryCheck() sees a null pointer, it exists, and the null pointer isn't subsequently used. Use MemoryCheck() instead of the one place where we manually checked for a null pointer and called memory_error(). Change-Id: Id6b0328cfd17cb14ec9d1e461420896a31573c71 Reviewed-on: https://code.wireshark.org/review/15851 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'tools/lemon')
-rw-r--r--tools/lemon/lemon.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c
index 3798f39742..295f93cf98 100644
--- a/tools/lemon/lemon.c
+++ b/tools/lemon/lemon.c
@@ -412,9 +412,9 @@ struct lemon {
char *argv0; /* Name of the program */
};
-void memory_error(void);
#define MemoryCheck(X) if((X)==0){ \
- memory_error(); \
+ fprintf(stderr,"Out of memory. Aborting...\n"); \
+ exit(1); \
}
/**************** From the file "table.h" *********************************/
@@ -1466,14 +1466,6 @@ void ErrorMsg(const char *filename, int lineno, const char *format, ...){
** Main program file for the LEMON parser generator.
*/
-/* Report an out-of-memory condition and abort. This function
-** is used mostly by the "MemoryCheck" macro in struct.h
-*/
-void memory_error(void){
- fprintf(stderr,"Out of memory. Aborting...\n");
- exit(1);
-}
-
/* Locates the basename in a string possibly containing paths,
* including forward-slash and backward-slash delimiters on Windows,
* and allocates a new string containing just the basename.
@@ -4533,9 +4525,7 @@ void SetSize(int n)
char *SetNew(void){
char *s;
s = (char*)calloc( size, 1);
- if( s==0 ){
- memory_error();
- }
+ MemoryCheck( s );
return s;
}