void free_FactList( FactList *source ) { if ( source ) { free_FactList( source->next ); free_TokenList( source->item ); free( source ); } }
void free_PlOperator( PlOperator *o ) { if ( o ) { free_PlOperator( o->next ); if ( o->name ) { free( o->name ); } free_FactList( o->params ); free_PlNode( o->preconds ); free_PlNode( o->effects ); free( o ); } }
void build_orig_constant_list( void ) { FactList *f, *nextf, *end = NULL; TokenList *t; Bool do_count; int objects_count = 0; gtypes = build_object_list_from_ttl( gglobal_type_tree_list, NULL ); free_FactList( gorig_constant_list ); gorig_constant_list = NULL; for ( f = gtypes; f; f = nextf ) { nextf = f->next; if ( strcmp( f->item->item, STANDARD_TYPE ) == SAME ) { do_count = TRUE; } else { do_count = FALSE; } for ( t = f->item->next; t; t = t->next ) { if ( !gorig_constant_list ) { end = new_FactList(); gorig_constant_list = end; } else { end->next = new_FactList(); end = end->next; } end->item = new_TokenList(); end->item->item = copy_Token( t->item ); end->item->next = new_TokenList(); end->item->next->item = copy_Token( f->item->item ); if ( do_count ) { /* count objects for RIFO meta strategy */ objects_count++; } } } }
void collect_all_strings( void ) { FactList *f; TokenList *t; int p_num, type_num, c_num, ar; int i; for ( f = gorig_constant_list; f; f = f->next ) { if ( (type_num = position_in_types_table( f->item->next->item )) == -1 ) { if ( gnum_types == MAX_TYPES ) { printf("\ntoo many types! increase MAX_TYPES (currently %d)\n\n", MAX_TYPES); exit( 1 ); } gtype_names[gnum_types] = new_Token( strlen( f->item->next->item ) + 1 ); strcpy( gtype_names[gnum_types], f->item->next->item ); gtype_size[gnum_types] = 0; for ( i = 0; i < MAX_CONSTANTS; i++ ) { gis_member[i][gnum_types] = FALSE; } type_num = gnum_types++; } if ( (c_num = position_in_constants_table( f->item->item )) == -1 ) { if ( gnum_constants == MAX_CONSTANTS ) { printf("\ntoo many constants! increase MAX_CONSTANTS (currently %d)\n\n", MAX_CONSTANTS); exit( 1 ); } gconstants[gnum_constants] = new_Token( strlen( f->item->item ) + 1 ); strcpy( gconstants[gnum_constants], f->item->item ); c_num = gnum_constants++; } if ( !gis_member[c_num][type_num] ) { if ( gtype_size[type_num] == MAX_TYPE ) { printf("\ntoo many consts in type %s! increase MAX_TYPE (currently %d)\n\n", gtype_names[type_num], MAX_TYPE); exit( 1 ); } gtype_consts[type_num][gtype_size[type_num]++] = c_num; gis_member[c_num][type_num] = TRUE; } } for ( f = gpredicates_and_types; f; f = f->next ) { if ( (p_num = position_in_predicates_table( f->item->item )) != -1 ) { printf("\npredicate %s declared twice!\n\n", f->item->item); exit( 1 ); } if ( gnum_predicates == MAX_PREDICATES ) { printf("\ntoo many predicates! increase MAX_PREDICATES (currently %d)\n\n", MAX_PREDICATES); exit( 1 ); } gpredicates[gnum_predicates] = new_Token( strlen( f->item->item ) + 1 ); strcpy( gpredicates[gnum_predicates], f->item->item ); ar = 0; for ( t = f->item->next; t; t = t->next ) { if ( (type_num = position_in_types_table( t->item )) == -1 ) { printf("\nwarning: predicate %s uses unknown or empty type %s\n\n", f->item->item, t->item); } if ( ar == MAX_ARITY ) { printf("\narity of %s to high! increase MAX_ARITY (currently %d)\n\n", gpredicates[gnum_predicates], MAX_ARITY); exit( 1 ); } gpredicates_args_type[gnum_predicates][ar++] = type_num; } garity[gnum_predicates++] = ar; } free_FactList( gorig_constant_list ); free_FactList( gpredicates_and_types ); free_FactList( gtypes ); }