//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void FreeFuzzySeperators_r(fuzzyseperator_t *fs) { if (!fs) return; if (fs->child) FreeFuzzySeperators_r(fs->child); if (fs->next) FreeFuzzySeperators_r(fs->next); FreeMemory(fs); } //end of the function FreeFuzzySeperators
/* ======================================================================================================================================= FreeFuzzySeperators_r ======================================================================================================================================= */ void FreeFuzzySeperators_r(fuzzyseperator_t *fs) { if (!fs) { return; } if (fs->child) { FreeFuzzySeperators_r(fs->child); } if (fs->next) { FreeFuzzySeperators_r(fs->next); } FreeMemory(fs); }
void FreeWeightConfig2(weightconfig_t *config) { int i; for (i = 0; i < config->numweights; i++) { FreeFuzzySeperators_r(config->weights[i].firstseperator); if (config->weights[i].name) FreeMemory(config->weights[i].name); } //end for FreeMemory(config); } //end of the function FreeWeightConfig2
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== fuzzyseperator_t *ReadFuzzySeperators_r( source_t *source ) { int newindent, index, def, founddefault; token_t token; fuzzyseperator_t *fs, *lastfs, *firstfs; founddefault = qfalse; firstfs = NULL; lastfs = NULL; if ( !PC_ExpectTokenString( source, "(" ) ) { return NULL; } if ( !PC_ExpectTokenType( source, TT_NUMBER, TT_INTEGER, &token ) ) { return NULL; } index = token.intvalue; if ( !PC_ExpectTokenString( source, ")" ) ) { return NULL; } if ( !PC_ExpectTokenString( source, "{" ) ) { return NULL; } if ( !PC_ExpectAnyToken( source, &token ) ) { return NULL; } do { def = !strcmp( token.string, "default" ); if ( def || !strcmp( token.string, "case" ) ) { fs = (fuzzyseperator_t *) GetClearedMemory( sizeof( fuzzyseperator_t ) ); fs->index = index; if ( lastfs ) { lastfs->next = fs; } else { firstfs = fs;} lastfs = fs; if ( def ) { if ( founddefault ) { SourceError( source, "switch already has a default" ); FreeFuzzySeperators_r( firstfs ); return NULL; } //end if fs->value = MAX_INVENTORYVALUE; founddefault = qtrue; } //end if else { if ( !PC_ExpectTokenType( source, TT_NUMBER, TT_INTEGER, &token ) ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if fs->value = token.intvalue; } //end else if ( !PC_ExpectTokenString( source, ":" ) || !PC_ExpectAnyToken( source, &token ) ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if newindent = qfalse; if ( !strcmp( token.string, "{" ) ) { newindent = qtrue; if ( !PC_ExpectAnyToken( source, &token ) ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if } //end if if ( !strcmp( token.string, "return" ) ) { if ( !ReadFuzzyWeight( source, fs ) ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if } //end if else if ( !strcmp( token.string, "switch" ) ) { fs->child = ReadFuzzySeperators_r( source ); if ( !fs->child ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if } //end else if else { SourceError( source, "invalid name %s", token.string ); return NULL; } //end else if ( newindent ) { if ( !PC_ExpectTokenString( source, "}" ) ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if } //end if } //end if else { FreeFuzzySeperators_r( firstfs ); SourceError( source, "invalid name %s", token.string ); return NULL; } //end else if ( !PC_ExpectAnyToken( source, &token ) ) { FreeFuzzySeperators_r( firstfs ); return NULL; } //end if } while ( strcmp( token.string, "}" ) ); // if ( !founddefault ) { SourceWarning( source, "switch without default" ); fs = (fuzzyseperator_t *) GetClearedMemory( sizeof( fuzzyseperator_t ) ); fs->index = index; fs->value = MAX_INVENTORYVALUE; fs->weight = 0; fs->next = NULL; fs->child = NULL; if ( lastfs ) { lastfs->next = fs; } else { firstfs = fs;} } //end if // return firstfs; } //end of the function ReadFuzzySeperators_r