diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-07-10 00:07:48 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-07-10 00:07:48 +0200 |
| commit | 96266332bfc5cef2bd06aa88f231999322e0513c (patch) | |
| tree | b6009e69d1ad79d11985d981f7ed790256e1435f /src/server | |
| parent | ec8bb7ab5a7aaabd1d8cbd159639b9f29ad4b8e6 (diff) | |
Fix memory leak
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/build.odin | 9 | ||||
| -rw-r--r-- | src/server/completion.odin | 6 | ||||
| -rw-r--r-- | src/server/documents.odin | 6 | ||||
| -rw-r--r-- | src/server/indexer.odin | 2 |
4 files changed, 9 insertions, 14 deletions
diff --git a/src/server/build.odin b/src/server/build.odin index 7fd26d1..741cf6b 100644 --- a/src/server/build.odin +++ b/src/server/build.odin @@ -49,8 +49,8 @@ try_build_package :: proc(pkg_name: string) { temp_arena: mem.Arena - mem.init_arena(&temp_arena, make([]byte, mem.Megabyte*25)) - + mem.init_arena(&temp_arena, make([]byte, mem.Megabyte*25, runtime.default_allocator())) + { context.allocator = mem.arena_allocator(&temp_arena) @@ -89,6 +89,7 @@ try_build_package :: proc(pkg_name: string) { if !ok { log.errorf("error in parse file for indexing %v", fullpath) + continue } uri := common.create_uri(fullpath, context.allocator) @@ -112,7 +113,7 @@ setup_index :: proc() { indexer.index = make_memory_index(symbol_collection) dir_exe := path.dir(os.args[0]) - + try_build_package(path.join(dir_exe, "builtin")) } @@ -126,4 +127,4 @@ log_error_handler :: proc(pos: tokenizer.Pos, msg: string, args: ..any) { log_warning_handler :: proc(pos: tokenizer.Pos, msg: string, args: ..any) { log.warnf("%v %v %v", pos, msg, args) -} +}
\ No newline at end of file diff --git a/src/server/completion.odin b/src/server/completion.odin index 786db8d..f64e2a8 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -79,9 +79,7 @@ get_completion_list :: proc(document: ^Document, position: common.Position, comp } if position_context.switch_type_stmt != nil && position_context.case_clause != nil { - if assign, ok := position_context.switch_type_stmt.tag.derived.(^ast.Assign_Stmt); ok && assign.rhs != nil && len(assign.rhs) == 1 { - ast_context.use_globals = true ast_context.use_locals = true @@ -163,7 +161,6 @@ get_directive_completion :: proc(ast_context: ^AstContext, position_context: ^Do } get_comp_lit_completion :: proc(ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { - items := make([dynamic]CompletionItem, context.temp_allocator) if position_context.parent_comp_lit.type == nil { @@ -815,7 +812,7 @@ get_identifier_completion :: proc(ast_context: ^AstContext, position_context: ^D list.isIncomplete = true - combined := make([dynamic]CombinedResult) + combined := make([dynamic]CombinedResult, context.temp_allocator) lookup_name := "" @@ -1062,7 +1059,6 @@ get_identifier_completion :: proc(ast_context: ^AstContext, position_context: ^D } get_package_completion :: proc(ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { - items := make([dynamic]CompletionItem, context.temp_allocator) list.isIncomplete = false diff --git a/src/server/documents.odin b/src/server/documents.odin index 335fc87..9f5be37 100644 --- a/src/server/documents.odin +++ b/src/server/documents.odin @@ -53,6 +53,8 @@ document_storage: DocumentStorage document_storage_shutdown :: proc() { for k, v in document_storage.documents { + common.scratch_allocator_destroy(v.allocator) + free(v.allocator) delete(k) } @@ -207,7 +209,6 @@ document_apply_changes :: proc(uri_string: string, changes: [dynamic]TextDocumen for change in changes { //for some reason sublime doesn't seem to care even if i tell it to do incremental sync if range, ok := change.range.(common.Range); ok { - absolute_range, ok := common.get_absolute_range(range, document.text[:document.used_text]) if !ok { @@ -245,7 +246,6 @@ document_apply_changes :: proc(uri_string: string, changes: [dynamic]TextDocumen copy(document.text[len(lower):], middle) } } else { - document.used_text = len(change.text) if document.used_text > len(document.text) { @@ -384,7 +384,7 @@ parse_document :: proc(document: ^Document, config: ^common.Config) -> ([]Parser context.allocator = common.scratch_allocator(document.allocator) pkg := new(ast.Package) - pkg.kind = .Normal + pkg.kind = .Normal pkg.fullpath = document.fullpath document.ast = ast.File { diff --git a/src/server/indexer.odin b/src/server/indexer.odin index cb24cec..581bd37 100644 --- a/src/server/indexer.odin +++ b/src/server/indexer.odin @@ -21,11 +21,9 @@ FuzzyResult :: struct { lookup :: proc(name: string, pkg: string, loc := #caller_location) -> (Symbol, bool) { if symbol, ok := memory_index_lookup(&indexer.index, name, pkg); ok { - log.infof("lookup name: %v pkg: %v, symbol %v location %v", name, pkg, symbol, loc) return symbol, true } - log.infof("lookup failed name: %v pkg: %v location %v", name, pkg, loc) return {}, false } |