diff --git a/apps/script_console.cpp b/apps/script_console.cpp index db4e592..64e65c9 100644 --- a/apps/script_console.cpp +++ b/apps/script_console.cpp @@ -2,8 +2,6 @@ #include #include -// TODO Check for heap allocation leaks. - struct Instance : EsInstance { EsCommand commandClearOutput; @@ -622,15 +620,19 @@ void AddREPLResult(ExecutionContext *context, EsElement *parent, Node *type, Val if (type->type == T_INT) { char *buffer = EsStringAllocateAndFormat(&bytes, "%d", value.i); EsTextDisplayCreate(parent, ES_CELL_H_FILL, &styleOutputData, buffer, bytes); + EsHeapFree(buffer); } else if (type->type == T_BOOL) { char *buffer = EsStringAllocateAndFormat(&bytes, "%z", value.i ? "true" : "false"); EsTextDisplayCreate(parent, ES_CELL_H_FILL, &styleOutputData, buffer, bytes); + EsHeapFree(buffer); } else if (type->type == T_NULL) { char *buffer = EsStringAllocateAndFormat(&bytes, "%z", "null"); EsTextDisplayCreate(parent, ES_CELL_H_FILL, &styleOutputData, buffer, bytes); + EsHeapFree(buffer); } else if (type->type == T_FLOAT) { char *buffer = EsStringAllocateAndFormat(&bytes, "%F", value.f); EsTextDisplayCreate(parent, ES_CELL_H_FILL, &styleOutputData, buffer, bytes); + EsHeapFree(buffer); } else if (type->type == T_STR) { EsAssert(context->heapEntriesAllocated > (uint64_t) value.i); HeapEntry *entry = &context->heap[value.i]; @@ -757,6 +759,16 @@ void ScriptThread(EsGeneric _instance) { AddOutput(instance, EsLiteral("\n")); } + while (fixedAllocationBlocks) { + void *block = fixedAllocationBlocks; + fixedAllocationBlocks = (void **) *fixedAllocationBlocks; + EsHeapFree(block); + } + + fixedAllocationCurrentBlock = nullptr; + fixedAllocationCurrentPosition = 0; + fixedAllocationCurrentSize = 0; + EsMessageMutexAcquire(); if (!instance->anyOutput) { diff --git a/desktop/api.cpp b/desktop/api.cpp index c2aa850..dd14e71 100644 --- a/desktop/api.cpp +++ b/desktop/api.cpp @@ -933,6 +933,7 @@ EsMessage *EsMessageReceive() { EsAssert(!api.workQueue.Length()); api.workThreads.Free(); api.workQueue.Free(); + api.connectedDevices.Free(); #ifdef ENABLE_POSIX_SUBSYSTEM POSIXCleanup(); #endif diff --git a/desktop/text.cpp b/desktop/text.cpp index 7b46580..73ea057 100644 --- a/desktop/text.cpp +++ b/desktop/text.cpp @@ -691,6 +691,8 @@ bool EsFontDatabaseLookupByID(EsFontFamily id, EsFontInformation *information) { } EsFontFamily EsFontDatabaseInsertFile(const EsFontInformation *information, EsFileStore *store) { + // TODO Locking. + FontInitialise(); EsAssert(store->handles); FontDatabaseEntry *entry = nullptr;