{"id":4280,"date":"2014-03-30T09:40:32","date_gmt":"2014-03-30T09:40:32","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/freeimage-delete-bitmap-data-fails-collection-of-common-programming-errors\/"},"modified":"2014-03-30T09:40:32","modified_gmt":"2014-03-30T09:40:32","slug":"freeimage-delete-bitmap-data-fails-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/freeimage-delete-bitmap-data-fails-collection-of-common-programming-errors\/","title":{"rendered":"FreeImage delete[] bitmap data fails-Collection of common programming errors"},"content":{"rendered":"<p>Please help me with cleaning up my heap after loading bitmap with FreeImage. Somehow <code>delete[] data;<\/code> causes <code>_ASSERTE(_CrtIsValidHeapPointer(pUserData))<\/code> assertion, and I cannot found how to fix it other than commenting this line. Will there memory leak? Any help and explanation will be appreciated!<\/p>\n<p>Full code at pastebin: http:\/\/pastebin.com\/dWxz0tjM<\/p>\n<p>Visual Studio 2012 solution (with huge FreeImage static lib): http:\/\/rghost.ru\/40322357 (15.7 Mbytes!)<\/p>\n<p>Full code here:<\/p>\n<pre><code>#include \n\n\/\/ FreeImage static linkage\n#define  FREEIMAGE_LIB\n#include \"FreeImage\/FreeImage.h\"\n#include \"FreeImage\/Utilities.h\"\n#pragma comment(lib, \"FreeImage\/FreeImaged.lib\")\n\nusing namespace std;\n\nstatic const wchar_t* sk_Filename = L\"Test.tga\";\n\n\/\/ Error handler to use in callback\nvoid FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *msg) \n{\n    char buf[1024];\n    sprintf_s(buf, 1024, \"Error: %s\", FreeImage_GetFormatFromFIF(fif));\n\n    cout<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Please help me with cleaning up my heap after loading bitmap with FreeImage. Somehow delete[] data; causes _ASSERTE(_CrtIsValidHeapPointer(pUserData)) assertion, and I cannot found how to fix it other than commenting this line. Will there memory leak? Any help and explanation will be appreciated! Full code at pastebin: http:\/\/pastebin.com\/dWxz0tjM Visual Studio 2012 solution (with huge FreeImage [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4280","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4280"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4280\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}