mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 06:08:41 +01:00
[0.4.0] Introduce WrenLoadModuleResult, fix unfreed strings from host. (#778)
This commit is contained in:
17
test/test.c
17
test/test.c
@ -364,7 +364,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
char* readModule(WrenVM* vm, const char* module)
|
||||
void readModuleComplete(WrenVM* vm, const char* module, WrenLoadModuleResult result)
|
||||
{
|
||||
if (result.source) {
|
||||
free((void*)result.source);
|
||||
result.source = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
WrenLoadModuleResult readModule(WrenVM* vm, const char* module)
|
||||
{
|
||||
|
||||
Path* filePath = pathNew(module);
|
||||
@ -375,8 +383,11 @@
|
||||
char* source = readFile(filePath->chars);
|
||||
pathFree(filePath);
|
||||
|
||||
//may or may not be null
|
||||
return source;
|
||||
//source may or may not be null
|
||||
WrenLoadModuleResult result;
|
||||
result.source = source;
|
||||
result.onComplete = readModuleComplete;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user