Commit Graph

5 Commits

Author SHA1 Message Date
Bob Nystrom
ab12bc97e0 fix: remove redundant free in setRootDirectory and fix memory leak in runFile 2015-06-27 06:01:07 +00:00
André Althaus
f6014d41e8 fix: free previously allocated rootDirectory before reassignment and clear on VM teardown
Add missing free of the old rootDirectory pointer in setRootDirectory to prevent
memory leaks when the function is called multiple times. Also set rootDirectory
to NULL via setRootDirectory after VM teardown in runFile to ensure the pointer
is properly cleared before program exit.
2015-06-03 19:48:26 +00:00
Bob Nystrom
7ed5603ffc refactor: rename package module loading to module directory loading in readModule
Rename the internal concept from "package" to "module directory" when loading
module.wren files from subdirectories. Update variable names (packageModule
to moduleDir, packageModulePath to moduleDirPath) and adjust early return
logic to free modulePath before checking contents. Add test for loading
module from a directory and remove old package module test.
2015-03-23 13:48:08 +00:00
Gavin Schulz
1374797192 feat: fall back to loading module package when module file not found
Extract file path construction into `wrenFilePath` helper and modify `readModule` to first attempt loading the module as a `.wren` file. If that fails, treat the module name as a package directory and try to load `module.wren` from within it. Add test files `module_package/module.wren` and `package_module.wren` to verify the new package resolution behavior.
2015-03-21 23:05:02 +00:00
Bob Nystrom
11a61b47ab feat: extract CLI file loading functions into separate io.c and io.h
Extract the static `readFile`, `readModule`, and `setRootDirectory` functions from main.c into a new io module, replacing the fixed-size `rootDirectory` array with a heap-allocated pointer and adding the corresponding header with public declarations.
2015-03-16 14:22:52 +00:00