Commit e88d4697 authored by emerit's avatar emerit
Browse files

remove py_decref for sysPath

parent 318e42a4
Loading
Loading
Loading
Loading
+8 −61
Original line number Diff line number Diff line
@@ -767,46 +767,20 @@ int main( int argc, char *argv[] )
    getcwd( current_path, MAX_PATH );
    strcpy( ivas_path, current_path );
    strcpy( ivas_path, current_path );
    char *tmpstr = strstr( ivas_path, "/binauralRenderer_interface" );
    tmpstr[0] = '\0';

#ifdef _WIN32
    wchar_t *pyPath = Py_GetPath();

    wprintf( L"pyPath = %ls\n", pyPath );

    size_t len = wcslen( pyPath ) + strlen( ivas_path ) + strlen( current_path ) + 3;

    wchar_t *myPyPath = malloc( len * sizeof( wchar_t ) );

    swprintf( myPyPath, len, L"%ls;%hs;%hs", pyPath, current_path, ivas_path );
    // swprintf( myPyPath, len, L"%ls", pyPath );

    wprintf( L"myPyPath = %ls\n", myPyPath );

    Py_SetPath( myPyPath );

    pyPath = Py_GetPath();

    wprintf( L"pyPath = %ls\n", pyPath );
    char *tmpstr = strstr( ivas_path, "\\binauralRenderer_interface" );
#else
    char *tmpstr = strstr( ivas_path, "/binauralRenderer_interface" );
#endif

    tmpstr[0] = '\0';
    Py_Initialize();

#ifndef _WIN32
    PyObject *sysPath = PySys_GetObject( (char *) "path" );
    PyList_Append( sysPath, ( PyUnicode_FromString( current_path ) ) );
    PyList_Append( sysPath, ( PyUnicode_FromString( ivas_path ) ) );
#endif

    if ( numpy_import_array( -1 ) == -1 )
    {
#ifdef _WIN32
        free( myPyPath );
#else
        Py_DECREF( sysPath );
#endif

        Py_Finalize();
        fprintf( stderr, "Cannot load numpy!\n\n" );
        usage_gen_crend_tables();
@@ -818,12 +792,6 @@ int main( int argc, char *argv[] )

    if ( sofa_load_func == NULL )
    {
#ifdef _WIN32
        free( myPyPath );
#else
        Py_DECREF( sysPath );
#endif

        Py_Finalize();
        fprintf( stderr, "SofaReader.py!\n\n" );
        usage_gen_crend_tables();
@@ -835,11 +803,6 @@ int main( int argc, char *argv[] )
    if ( ret == 0 )
    {
        Py_DECREF( sofa_load_func );
#ifdef _WIN32
        free( myPyPath );
#else
        Py_DECREF( sysPath );
#endif

        Py_Finalize();
        fprintf( stderr, "error reading SofaReader.py!\n\n" );
@@ -852,11 +815,6 @@ int main( int argc, char *argv[] )
    if ( sofa_find_dir_func == NULL )
    {
        Py_DECREF( sofa_load_func );
#ifdef _WIN32
        free( myPyPath );
#else
        Py_DECREF( sysPath );
#endif

        Py_Finalize();
        fprintf( stderr, "error reading SofaReader.py!\n\n" );
@@ -870,11 +828,6 @@ int main( int argc, char *argv[] )
    {
        Py_DECREF( sofa_find_dir_func );
        Py_DECREF( sofa_load_func );
#ifdef _WIN32
        free( myPyPath );
#else
        Py_DECREF( sysPath );
#endif

        Py_Finalize();
        fprintf( stderr, "SofaReader.py!\n\n" );
@@ -994,12 +947,6 @@ int main( int argc, char *argv[] )
    Py_DECREF( sofa_find_dir_func );
    Py_DECREF( sofa_load_func );

#ifdef _WIN32
    free( myPyPath );
#else
    Py_DECREF( sysPath );
#endif

    Py_Finalize();
#endif