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.

This commit is contained in:
ehouse 2006-07-22 16:03:14 +00:00
parent de0c62fb39
commit d43acd6b46

View file

@ -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