X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/24c41ec5a0a323619b842a0df4e3844e2f9e68e3..bc797f4cc8ffe36277ba8b7dd4b57e63a96bfcb5:/src/common/imagxpm.cpp?ds=sidebyside diff --git a/src/common/imagxpm.cpp b/src/common/imagxpm.cpp index b8996eaafe..22584d6655 100644 --- a/src/common/imagxpm.cpp +++ b/src/common/imagxpm.cpp @@ -129,7 +129,7 @@ bool wxXPMHandler::SaveFile(wxImage * image, // 2. write the header: char tmpbuf[200]; - // VS: 200b is safe upper bound for anything produced by sprintf bellow + // VS: 200b is safe upper bound for anything produced by sprintf below // (101 bytes the string, neither %i can expand into more than 10 chars) sprintf(tmpbuf, "/* XPM */\n" @@ -141,7 +141,6 @@ bool wxXPMHandler::SaveFile(wxImage * image, // 3. create color symbols table: wxHashTable table(wxKEY_INTEGER); - table.DeleteContents(TRUE); image->ComputeHistogram(table); char *symbols_data = new char[cols * (chars_per_pixel+1)]; @@ -209,9 +208,17 @@ bool wxXPMHandler::SaveFile(wxImage * image, tmp = wxT("};\n"); stream.Write(tmp.mb_str(), 3); + // Clean up: delete[] symbols; delete[] symbols_data; + // FIXME: it will be better to use macros-based wxHashTable & DeleteContents(TRUE) + table.BeginFind(); + while ((node = table.Next()) != NULL) + { + delete (wxHNode *) node->GetData(); + } + return TRUE; }