Commit 904fb758 authored by emerit's avatar emerit
Browse files

fix memory leak

parent 3a25ea11
Loading
Loading
Loading
Loading
+10 −13
Original line number Diff line number Diff line
@@ -791,10 +791,7 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c
    double a[3] = { 0 };
    double t[3] = { 0 };
    long nearest;
    /*------------------------------------------------------------------------------------------*
     * Parse command line and initialize renderer
     *------------------------------------------------------------------------------------------*/
    /* Optional arguments */

    sofa_file_path = (char *) malloc( sizeof( char ) * ( strlen( file_path ) + 1 ) );
    if ( sofa_file_path == NULL )
    {
@@ -822,6 +819,8 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c
        return -1;
    }

    matClose( mat_fp );

    mwSize total_num_of_elements;
    mwIndex index = 0;
    int number_of_fields, field_index;
@@ -875,9 +874,9 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c
                                       field_index );
            if ( data == NULL )
            {
                mxDestroyArray( sofa );
                printf( "\tEmpty Field for %s\n", field_name );
                free( sofa_file_path );
                matClose( mat_fp );
                return -1;
            }

@@ -921,9 +920,9 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c
                                                                 field_index ) );
            if ( sofa_src_pos_cart_val == NULL )
            {
                mxDestroyArray( sofa );
                printf( "\tEmpty Field for %s\n", field_name );
                free( sofa_file_path );
                matClose( mat_fp );
                return -1;
            }
        }
@@ -934,9 +933,9 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c
                                                            field_index ) );
            if ( sofa_src_pos_val == NULL )
            {
                mxDestroyArray( sofa );
                printf( "\tEmpty Field for %s\n", field_name );
                free( sofa_file_path );
                matClose( mat_fp );
                return -1;
            }
        }
@@ -978,7 +977,7 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c
    uint32_t maxDel48kHz = 0;
    if ( index_pos == NULL )
    {
        matClose( mat_fp );
        mxDestroyArray( sofa );
        free( sofa_file_path );
        fprintf( stderr, "Cannot alloc sofa_file_path !\n\n" );
        return -1;
@@ -1014,19 +1013,17 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c

            if ( fabs( t[0] - a[0] ) > MAX_DIFF_AZI )
            {
                mxDestroyArray( sofa );
                fprintf( stderr, "Nearest position to far from target incomplete sofa file\n" );
                free( sofa_file_path );
                free( index_pos );
                matClose( mat_fp );

                return -1;
            }
            if ( fabs( t[1] - a[1] ) > MAX_DIFF_ELE )
            {
                mxDestroyArray( sofa );
                fprintf( stderr, "Nearest position to far from target incomplete sofa file\n" );
                free( sofa_file_path );
                matClose( mat_fp );

                return -1;
            }
            if ( a[0] > 180. )
@@ -1278,7 +1275,7 @@ int generate_crend_ivas_tables_from_sofa( const char *file_path, ConfigReader *c
        ivas_hrtf_close( &hrtf_data );
    }

    matClose( mat_fp );
    mxDestroyArray( sofa );

    if ( sofa_file_path )
        free( sofa_file_path );