Hi
Does anyone know why the following code causes me a memory leak:
HGLOBAL hGlobal = GlobalAlloc( GMEM_FIXED, aJpegSize );
void* p = GlobalLock(hGlobal);
memcpy((char *)p,imageptr,aJpegSize);
GlobalUnlock(hGlobal);
IStream* pStream = NULL;
if ( CreateStreamOnHGlobal( hGlobal, TRUE, &pStream ) == S_OK);
{
if ( aPicture == NULL )
delete aPicture;
aPicture = Image::FromStream(pStream,0);
}
pStream->Release();
GlobalFree(hGlobal);
<< moderator edit: added [code][/code] tags >>
NOTE: the imageptr is a pointer to my jpeg image, and aJpegSize is the size of the image. I later go on to do:
Graphics graphics( dc );
graphics.DrawImage( w->aPicture, 0, 0, 320, 240 );
I'm really stuck, any idea could help!
Thanks in advance,
maldini