From d523f615beab84b9ce6224c42d8555c619825e31 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 14 Apr 2017 19:24:05 -0700 Subject: Make memory_error() a routine. That makes the code more like Lemon as distributed. Note that Lemon, as distributed, at least claims to have a bunch of stuff "From the file "XXX.{c,h}", which might be the result of lemon.c being an "amalgamation": https://www.sqlite.org/amalgamation.html although, unlike SQLite, the individual bits of the amalgamation don't appear to be present in the SQLite Fossil repository, so maybe they've been permanently glued together. Change-Id: I361d0d16be0744b127110d7d237fdd84e30b6432 Reviewed-on: https://code.wireshark.org/review/21105 Petri-Dish: Guy Harris Reviewed-by: Guy Harris --- tools/lemon/lemon.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c index e5d1a4f18e..68f7071adc 100644 --- a/tools/lemon/lemon.c +++ b/tools/lemon/lemon.c @@ -422,8 +422,8 @@ struct lemon { }; #define MemoryCheck(X) if((X)==0){ \ - fprintf(stderr,"Out of memory. Aborting...\n"); \ - exit(1); \ + extern void memory_error(void); \ + memory_error(); \ } /**************** From the file "table.h" *********************************/ @@ -1513,6 +1513,14 @@ make_basename(char* fullname) return new_string; } +/* 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); +} + static int nDefine = 0; /* Number of -D options on the command line */ static char **azDefine = 0; /* Name of the -D macros */ -- cgit v1.2.1