diff --git a/GUI/extensions.cpp b/GUI/extensions.cpp index 9893e5a..54b5e95 100644 --- a/GUI/extensions.cpp +++ b/GUI/extensions.cpp @@ -28,7 +28,7 @@ std::map LoadExtensions() bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map miscInfo) { bool success = true; - wchar_t* sentenceBuffer = (wchar_t*)malloc((sentence.size() + 1) * sizeof(wchar_t)); + wchar_t* sentenceBuffer = (wchar_t*)HeapAlloc(GetProcessHeap(), 0, (sentence.size() + 1) * sizeof(wchar_t)); wcscpy_s(sentenceBuffer, sentence.size() + 1, sentence.c_str()); InfoForExtension* miscInfoLinkedList = new InfoForExtension; InfoForExtension* miscInfoTraverser = miscInfoLinkedList; @@ -40,12 +40,12 @@ bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_mapnext) if (propertyName == i->name) return i->value; - return 0; + throw; } }; @@ -29,7 +29,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo); * You shouldn't mess with this or even look at it unless you're certain you know what you're doing. * Param sentence: pointer to sentence received by Textractor (UTF-16). * You should not modify this sentence. If you want Textractor to receive a modified sentence, copy it into your own buffer and return that. - * Please allocate the buffer using malloc() and not new[] or something else: Textractor uses free() to free it. + * Please allocate the buffer using HeapAlloc() and not new[] or malloc() or something else: Textractor uses HeapFree() to free it. * Param miscInfo: pointer to start of singly linked list containing misc info about the sentence. * Return value: pointer to sentence Textractor takes for future processing and display. * Return 'sentence' unless you created a new sentence/buffer as mentioned above. @@ -42,7 +42,7 @@ extern "C" __declspec(dllexport) const wchar_t* OnNewSentence(const wchar_t* sen if (ProcessSentence(sentence, SentenceInfo{ miscInfo })) { // No need to worry about freeing this: Textractor does it for you. - wchar_t* newSentence = (wchar_t*)malloc((sentence.size() + 1) * sizeof(wchar_t*)); + wchar_t* newSentence = (wchar_t*)HeapAlloc(GetProcessHeap(), 0, (sentence.size() + 1) * sizeof(wchar_t)); wcscpy_s(newSentence, sentence.size() + 1, sentence.c_str()); return newSentence; }