aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2020-12-10 12:24:34 +0100
committerDanielGavin <danielgavin5@hotmail.com>2020-12-10 12:24:34 +0100
commitd5292bcd9c67893804929a4095d4a064ed2b00ce (patch)
tree7f51f4d211438c6118584976b45f2b0ee97876d3 /src/server
parent31e8c8686af972b033ba9567d7f34cf4cadf7f10 (diff)
fixed memory leaks.
Diffstat (limited to 'src/server')
-rw-r--r--src/server/analysis.odin2
-rw-r--r--src/server/documents.odin17
-rw-r--r--src/server/requests.odin34
3 files changed, 37 insertions, 16 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 49a53ac..5990d1d 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -960,7 +960,7 @@ make_int_ast :: proc() -> ^ast.Ident {
get_package_from_node :: proc(node: ast.Node) -> string {
slashed, _ := filepath.to_slash(node.pos.file, context.temp_allocator);
- ret := strings.to_lower(path.dir(slashed, context.temp_allocator));
+ ret := strings.to_lower(path.dir(slashed, context.temp_allocator), context.temp_allocator);
return ret;
}
diff --git a/src/server/documents.odin b/src/server/documents.odin
index 87c83c3..7e9aa67 100644
--- a/src/server/documents.odin
+++ b/src/server/documents.odin
@@ -49,6 +49,17 @@ DocumentStorage :: struct {
document_storage: DocumentStorage;
document_storage_shutdown :: proc() {
+
+ for k, v in document_storage.documents {
+ delete(k);
+ }
+
+ for alloc in document_storage.free_allocators {
+ common.scratch_allocator_destroy(alloc);
+ free(alloc);
+ }
+
+ delete(document_storage.free_allocators);
delete(document_storage.documents);
}
@@ -387,12 +398,12 @@ parse_document :: proc(document: ^Document, config: ^common.Config) -> ([] Parse
for imp, index in document.ast.imports {
- //ERROR no completion on imp!
-
//collection specified
if i := strings.index(imp.fullpath, ":"); i != -1 && i > 1 {
- //Note(Daniel, assuming absolute path atm, but that will change)
+ if len(imp.fullpath) < 2 {
+ continue;
+ }
collection := imp.fullpath[1:i];
p := imp.fullpath[i+1:len(imp.fullpath)-1];
diff --git a/src/server/requests.odin b/src/server/requests.odin
index 66d3dbf..3511e49 100644
--- a/src/server/requests.odin
+++ b/src/server/requests.odin
@@ -40,6 +40,7 @@ RequestType :: enum {
};
RequestInfo :: struct {
+ root: json.Value,
params: json.Value,
document: ^Document,
id: RequestId,
@@ -242,6 +243,7 @@ handle_request :: proc(request: json.Value, config: ^common.Config, writer: ^Wri
info := new(RequestInfo);
+ info.root = request;
info.params = root["params"];
info.id = id;
info.config = config;
@@ -366,7 +368,7 @@ request_initialize :: proc(task: ^common.Task) {
using info;
- defer json.destroy_value(params);
+ defer json.destroy_value(root);
defer free(info);
params_object, ok := params.value.(json.Object);
@@ -506,6 +508,10 @@ request_initialize :: proc(task: ^common.Task) {
request_initialized :: proc(task: ^common.Task) {
info := get_request_info(task);
+
+ using info;
+
+ json.destroy_value(root);
free(info);
}
@@ -515,7 +521,7 @@ request_shutdown :: proc(task: ^common.Task) {
using info;
- defer json.destroy_value(params);
+ defer json.destroy_value(root);
defer free(info);
response := make_response_message(
@@ -536,7 +542,7 @@ request_definition :: proc(task: ^common.Task) {
defer document_release(document);
defer free(info);
- defer json.destroy_value(params);
+ defer json.destroy_value(root);
params_object, ok := params.value.(json.Object);
@@ -574,7 +580,7 @@ request_completion :: proc(task: ^common.Task) {
using info;
defer document_release(document);
- defer json.destroy_value(params);
+ defer json.destroy_value(root);
defer free(info);
params_object, ok := params.value.(json.Object);
@@ -616,7 +622,7 @@ request_signature_help :: proc(task: ^common.Task) {
using info;
defer document_release(document);
- defer json.destroy_value(params);
+ defer json.destroy_value(root);
defer free(info);
params_object, ok := params.value.(json.Object);
@@ -647,6 +653,10 @@ request_signature_help :: proc(task: ^common.Task) {
notification_exit :: proc(task: ^common.Task) {
info := get_request_info(task);
using info;
+
+ defer json.destroy_value(root);
+ defer free(info);
+
config.running = false;
}
@@ -656,7 +666,7 @@ notification_did_open :: proc(task: ^common.Task) {
using info;
- defer json.destroy_value(params);
+ defer json.destroy_value(root);
defer free(info);
params_object, ok := params.value.(json.Object);
@@ -686,7 +696,7 @@ notification_did_change :: proc(task: ^common.Task) {
using info;
- defer json.destroy_value(params);
+ defer json.destroy_value(root);
defer free(info);
params_object, ok := params.value.(json.Object);
@@ -713,7 +723,7 @@ notification_did_close :: proc(task: ^common.Task) {
using info;
- defer json.destroy_value(params);
+ defer json.destroy_value(root);
defer free(info);
params_object, ok := params.value.(json.Object);
@@ -741,7 +751,7 @@ notification_did_save :: proc(task: ^common.Task) {
using info;
- json.destroy_value(params);
+ json.destroy_value(root);
free(info);
}
@@ -752,7 +762,7 @@ request_semantic_token_full :: proc(task: ^common.Task) {
using info;
defer document_release(document);
- defer json.destroy_value(params);
+ defer json.destroy_value(root);
defer free(info);
params_object, ok := params.value.(json.Object);
@@ -799,7 +809,7 @@ request_semantic_token_range :: proc(task: ^common.Task) {
params_object, ok := params.value.(json.Object);
defer document_release(document);
- defer json.destroy_value(params);
+ defer json.destroy_value(root);
defer free(info);
if !ok {
@@ -832,7 +842,7 @@ request_document_symbols :: proc(task: ^common.Task) {
using info;
defer document_release(document);
- defer json.destroy_value(params);
+ defer json.destroy_value(root);
defer free(info);
params_object, ok := params.value.(json.Object);