示例#1
0
player::~player()
{
    // Clean up gameswf as much as possible, so valgrind will help find actual leaks.
    // Maximum release of resources.  Calls clear_library() and
    // fontlib::clear(), and also clears some extra internal stuff
    // that may have been allocated (e.g. global ActionScript
    // objects).  This should get all gameswf structures off the
    // heap, with the exception of any objects that are still
    // referenced by the host program and haven't had drop_ref()
    // called on them.

    m_current_root = NULL;
    m_global = NULL;
    --s_player_count;

    clear_heap();

    gameswf_engine_mutex().lock();

    clear_library();

    // Clear shared stuff only when all players are deleted
    if (s_player_count == 0)
    {
        clears_tag_loaders();
        clear_shared_libs();
        clear_registered_type_handlers();
        clear_standard_method_map();
        clear_disasm();
        delete s_glyph_provider;
        s_glyph_provider = NULL;
    }

    gameswf_engine_mutex().unlock();

    action_clear();
}
示例#2
0
static void clear_all( struct Ordered_container* lib_title, struct Ordered_container* lib_ID, struct Ordered_container* catalog, char* message )
{
    clear_container( catalog, ( void(*)(void*) )destroy_Collection, "" );
    /*clear_container(lib_ID, ( void(*)(void*) )destroy_Record, "") ;*/
    clear_library(lib_title, lib_ID, catalog, message );
}
示例#3
0
int main( void )
{
    int i;
    
    /* holds both command characters */
    char command[ 2 ];
    
    /* set up the three libraries */
    struct Ordered_container* lib_title = OC_create_container( comp_Record_by_title );
    struct Ordered_container* lib_ID    = OC_create_container( comp_Record_by_ID );
    struct Ordered_container* catalog   = OC_create_container( comp_Collection_by_name );
    
    for ( ; ; )
    {
        printf( "\nEnter command: " );
        
        /* load the command chars */
        for ( i = 0 ; i < 2; ++i)
        {
            command[ i ] = get_command_char();
        }
        
        switch ( command[ 0 ] )
        {
            case 'f' :/* find (records only)*/
                switch ( command[ 1 ] )
                {
                    case 'r' :
                        find_record_print( lib_title );
                        break;
                    default:
                        print_error_clear( "Unrecognized command!\n");
                        break;
                }
                break;
            case 'p' : /* print */
                switch ( command[ 1 ] )
                {
                    case 'r' :
                        print_record( lib_ID );
                        break;
                    case 'L':
                        print_containter( lib_title, "Library", "records", (void (*)(void*))print_Record );
                        break;
                    case 'C':
                        /* print_catalog( catalog ); */
                        print_containter( catalog, "Catalog", "collections", (void (*)(void*))print_Collection );
                        break;
                    case 'a': /* allocation */
                        print_allocation( lib_title, lib_ID, catalog );
                        break;
                    case 'c':
                        print_collection_main( catalog );
                        break;
                    default:
                        print_error_clear( "Unrecognized command!\n");
                        break;
                }
                break;
            case 'm': /* modify (rating only) */
                switch ( command[ 1 ] )
                {
                    case 'r':
                        modify_rating( lib_ID );
                        break;
                    default:
                        print_error_clear( "Unrecognized command!\n");
                        break;
                }
                break;
            case 'a' : /* add */
                switch ( command[ 1 ] )
                {
                    case 'r' :
                        add_record( lib_title, lib_ID );
                        break;
                    case 'c':
                        add_coll( catalog );
                        break;
                    case 'm':
                        add_member( lib_ID , catalog );
                        break;
                    case 'a': /* allocation */
                        /* throw error */
                        print_error_clear( "Unrecognized command!\n");
                        break;
                    default:
                        break;
                }
                break;
            case 'd': /* delete */
                switch ( command[ 1 ] )
                {
                    case 'r' :
                        delete_record( lib_title, lib_ID, catalog );
                        break;
                    case 'c':
                        delete_collection( catalog );
                        break;
                    case 'm':
                         remove_member( lib_ID , catalog );
                        break;
                    case 'a': /* allocation */
                        /* throw error */
                        break;
                    default:
                        print_error_clear( "Unrecognized command!\n");
                        break;
                }
                break;
            case 'c': /* clear */
                switch ( command[ 1 ] )
                {
                    case 'L':
                        clear_library( lib_title, lib_ID, catalog, "All records deleted\n" );
                        break;
                    case 'C':
                        clear_container( catalog, ( void(*)(void*) )destroy_Collection, "All collections deleted\n" );
                        break;
                    case 'A':
                        clear_all(lib_title, lib_ID, catalog, "All data deleted\n" );
                        break;
                    default:
                        print_error_clear( "Unrecognized command!\n");
                        break;
                }
                break;
            case 's': /* save */
                switch ( command[ 1 ] ) {
                    case 'A':
                        save_all_to_file( lib_title, catalog );
                        break;
                    default:
                        print_error_clear( "Unrecognized command!\n");
                        break;
                }
                break;
            case 'r': /* restore */
                switch ( command[ 1 ] ) {
                    case 'A':
                        load_from_file( lib_title, lib_ID, catalog );
                        break;
                    default:
                        print_error_clear( "Unrecognized command!\n");
                        break;
                }
                break;
            case 'q':
                switch ( command[ 1 ] )
                {
                    case 'q':
                        /* clean up memory */
                        quit( lib_title, lib_ID, catalog );
                        break;
                    default:
                        print_error_clear( "Unrecognized command!\n");
                        break;
                }
            default:
                /* throw error for bad input */
                print_error_clear( "Unrecognized command!\n");
                break;
        }
    }
	return 0;
}