Watch
1
0
Fork
You've already forked nexus
0
forked from Nexus/nexus

fix memory leaks

Oops! They were pretty slow, but still adds up. This might fix the bug that was stopping Nexus from working on GraphineOS.
This commit is contained in:
Henry Hiles 2026-09-19 21:13:03 -04:00
commit 673c5bd894
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
2 changed files with 16 additions and 11 deletions

2
gomuks

@ -1 +1 @@
Subproject commit 9e45ee426cc8be0bfada269f4abc4957c30e994e
Subproject commit c20070298d450cc02f465a503a5a52fea74af0d5

View file

@ -60,10 +60,12 @@ class ClientController extends AsyncNotifier<int> {
"GOMUKS_CACHE_HOME": (await getApplicationCacheDirectory()).path,
};
for (final MapEntry(:key, :value) in env.entries) {
GomuksSetEnv(
key.toNativeUtf8().cast<Char>(),
value.toNativeUtf8().cast<Char>(),
);
final keyPtr = key.toNativeUtf8().cast<Char>();
final valuePtr = value.toNativeUtf8().cast<Char>();
GomuksSetEnv(keyPtr, valuePtr);
calloc
..free(keyPtr)
..free(valuePtr);
}
}
final handle = await Isolate.run(GomuksInit);
@ -193,14 +195,17 @@ class ClientController extends AsyncNotifier<int> {
return response == null ? null : .fromJson(response);
}
Future<dynamic> _sendCommand(
dynamic _sendCommand(
String command, [
Map<String, dynamic> data = const {},
]) => callGomuksMethod(
data,
(handle, data) async =>
GomuksSubmitCommand(handle, command.toNativeUtf8().cast<Char>(), data),
);
]) => callGomuksMethod(data, (handle, data) {
final commandPointer = command.toNativeUtf8().cast<Char>();
try {
return GomuksSubmitCommand(handle, commandPointer, data);
} finally {
calloc.free(commandPointer);
}
});
Future<void> redactEvent(RedactEventRequest report) =>
_sendCommand("redact_event", report.toJson());