From d43acd6b46b4af4cebd37a3420d081ef1607c320 Mon Sep 17 00:00:00 2001 From: ehouse Date: Sat, 22 Jul 2006 16:03:14 +0000 Subject: [PATCH] check for remaining memory being < 0, not just <=, since we allocate exactly as much as we need. Fixes failure due to being out of memory at same time as having finished parsing stdin. --- xwords4/dawg/dict2dawg.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xwords4/dawg/dict2dawg.cpp b/xwords4/dawg/dict2dawg.cpp index b43f43bda..b29cccd06 100644 --- a/xwords4/dawg/dict2dawg.cpp +++ b/xwords4/dawg/dict2dawg.cpp @@ -610,7 +610,7 @@ parseAndSort( FILE* infile ) if ( eof ) { break; } - if ( memleft <= 0 ) { + if ( memleft < 0 ) { ERROR_EXIT( "no memory left\n" ); } } @@ -743,11 +743,11 @@ MakeTrieNode( int letter, bool isTerminal, int firstChildOffset, static void writeOutStartNode( const char* startNodeOut, int firstRootChildOffset ) { - FILE* NODEOUT; - NODEOUT = fopen( startNodeOut, "w" ); + FILE* nodeout; + nodeout = fopen( startNodeOut, "w" ); unsigned long be = htonl( firstRootChildOffset ); - (void)fwrite( &be, sizeof(be), 1, NODEOUT ); - fclose( NODEOUT ); + (void)fwrite( &be, sizeof(be), 1, nodeout ); + fclose( nodeout ); } // writeOutStartNode // build the hash for translating. I'm using a hash assuming it'll be