aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-06-10 22:00:19 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-06-10 22:00:19 -0400
commit21192b733d36ad983cf23efaf5e60fe7a245c405 (patch)
treee9ec711173aededc360f6a0bab4aa52875e8ebcc /src
parent3f089f4d757e2a705056eb331c74442ab48862aa (diff)
Fix memory leak in tests and replace deprecated `append_bits_128`
Diffstat (limited to 'src')
-rw-r--r--src/server/collector.odin23
-rw-r--r--src/server/marshal.odin6
-rw-r--r--src/testing/testing.odin10
3 files changed, 4 insertions, 35 deletions
diff --git a/src/server/collector.odin b/src/server/collector.odin
index 643f212..c757e74 100644
--- a/src/server/collector.odin
+++ b/src/server/collector.odin
@@ -74,28 +74,7 @@ make_symbol_collection :: proc(allocator := context.allocator, config: ^common.C
}
delete_symbol_collection :: proc(collection: SymbolCollection) {
- for k, v in collection.packages {
- for k2, v2 in v.symbols {
- free_symbol(v2, collection.allocator)
- }
- }
-
- for k, v in collection.unique_strings {
- delete(v, collection.allocator)
- }
-
- for k, v in collection.packages {
- for k2, v2 in v.methods {
- delete(v2)
- }
- delete(v.methods)
- delete(v.objc_structs)
- delete(v.symbols)
- delete(v.imports)
- }
-
- delete(collection.packages)
- delete(collection.unique_strings)
+ free_all(collection.allocator)
}
collect_procedure_fields :: proc(
diff --git a/src/server/marshal.odin b/src/server/marshal.odin
index dc816e0..c559862 100644
--- a/src/server/marshal.odin
+++ b/src/server/marshal.odin
@@ -156,13 +156,13 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
if opt.write_uint_as_hex && (opt.spec == .JSON5 || opt.spec == .MJSON) {
switch i in a {
case u8, u16, u32, u64, u128:
- s = strconv.append_bits_128(buf[:], u, 16, info.signed, 8 * ti.size, "0123456789abcdef", {.Prefix})
+ s = strconv.write_bits_128(buf[:], u, 16, info.signed, 8 * ti.size, "0123456789abcdef", {.Prefix})
case:
- s = strconv.append_bits_128(buf[:], u, 10, info.signed, 8 * ti.size, "0123456789", nil)
+ s = strconv.write_bits_128(buf[:], u, 10, info.signed, 8 * ti.size, "0123456789", nil)
}
} else {
- s = strconv.append_bits_128(buf[:], u, 10, info.signed, 8 * ti.size, "0123456789", nil)
+ s = strconv.write_bits_128(buf[:], u, 10, info.signed, 8 * ti.size, "0123456789", nil)
}
io.write_string(w, s) or_return
diff --git a/src/testing/testing.odin b/src/testing/testing.odin
index 303f577..87f740a 100644
--- a/src/testing/testing.odin
+++ b/src/testing/testing.odin
@@ -117,19 +117,9 @@ setup :: proc(src: ^Source) {
@(private)
teardown :: proc(src: ^Source) {
- //A lot of these deletes are managed by other systems in ols, but to simplify it, we just delete them here in tests.
-
server.free_index()
server.indexer.index = {}
- delete(src.document.package_name)
-
- for k, v in server.build_cache.loaded_pkgs {
- delete(k)
- }
-
- delete(server.build_cache.loaded_pkgs)
-
common.scratch_allocator_destroy(src.document.allocator)
}