Skip to content

Commit

Permalink
improve comments for load_module(); add dll cleanup in probe
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Nov 4, 2024
1 parent f684541 commit 63db4d1
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/core/chuck_compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,28 +1207,31 @@ t_CKBOOL Chuck_Compiler::bind( f_ck_query query_func, const string & name,

//-----------------------------------------------------------------------------
// name: load_module()
// desc: load a dll and add it
// desc: load an internal module and add it to the type system
//-----------------------------------------------------------------------------
t_CKBOOL load_module( Chuck_Compiler * compiler, Chuck_Env * env, f_ck_query query,
const char * name, const char * nspc )
{
Chuck_DLL * dll = NULL;
t_CKBOOL query_failed = FALSE;

// load osc
// create a DLL as a module (here DLL is not actually dynamically loaded
// from disk, but rather is a construct that contains a query function
dll = new Chuck_DLL( compiler->carrier(), name );
// (fixed: 1.3.0.0) query_failed now catches either failure of load or query
query_failed = !(dll->load( query ) && dll->query());
// check and add contents to type system
if( query_failed || !type_engine_add_dll( env, dll, nspc ) )
{
EM_error2( 0, "internal error loading module '%s.%s'...",
nspc, name );
if( query_failed )
EM_error2( 0, "...(reason: %s)", dll->last_error() );

// print error
EM_error2( 0, "internal error loading module '%s.%s'...", nspc, name );
// print error if it came from DLL query
if( query_failed ) { EM_error2( 0, "...(reason: %s)", dll->last_error() ); }
// done
return FALSE;
}

// TODO: SAFE_DELETE( dll ) -- possibly in both error and success cases?
return TRUE;
}

Expand Down Expand Up @@ -1934,6 +1937,9 @@ t_CKBOOL Chuck_Compiler::probe_external_chugin( const string & path, const strin
EM_poplog();
}

// clean up | 1.5.4.1 (ge) added
CK_SAFE_DELETE( dll );

// done
return TRUE;
}
Expand Down

0 comments on commit 63db4d1

Please sign in to comment.