plug leak: DeleteObject can't nuke an object CE didn't create

This commit is contained in:
ehouse 2008-09-14 16:06:18 +00:00
parent 4d7a781673
commit 82030b5382

View file

@ -256,6 +256,7 @@ ceCountSpecials( CEDictionaryCtxt* ctxt )
return result; return result;
} /* ceCountSpecials */ } /* ceCountSpecials */
#if 0
static void static void
printBitmapData1( XP_U16 nCols, XP_U16 nRows, XP_U8* data ) printBitmapData1( XP_U16 nCols, XP_U16 nRows, XP_U8* data )
{ {
@ -300,7 +301,6 @@ printBitmapData2( XP_U16 nCols, XP_U16 nRows, XP_U8* data )
} }
} /* printBitmapData2 */ } /* printBitmapData2 */
#if 0
static void static void
longSwapData( XP_U8* destBase, XP_U16 nRows, XP_U16 rowBytes ) longSwapData( XP_U8* destBase, XP_U16 nRows, XP_U16 rowBytes )
{ {
@ -370,14 +370,24 @@ ceMakeBitmap( CEDictionaryCtxt* XP_UNUSED_DBG(ctxt), XP_U8** ptrp )
} }
} }
printBitmapData1( nCols, nRows, savedDest ); /* printBitmapData1( nCols, nRows, savedDest ); */
printBitmapData2( nCols, nRows, savedDest ); /* printBitmapData2( nCols, nRows, savedDest ); */
} }
*ptrp = ptr; *ptrp = ptr;
return (XP_Bitmap*)bitmap; return (XP_Bitmap*)bitmap;
} /* ceMakeBitmap */ } /* ceMakeBitmap */
static void
ceDeleteBitmap( const CEDictionaryCtxt* ctxt, XP_Bitmap* bitmap )
{
if ( !!bitmap ) {
CEBitmapInfo* bmi = (CEBitmapInfo*)bitmap;
XP_FREE( ctxt->super.mpool, bmi->bits );
XP_FREE( ctxt->super.mpool, bmi );
}
}
static void static void
ce_dict_destroy( DictionaryCtxt* dict ) ce_dict_destroy( DictionaryCtxt* dict )
{ {
@ -396,14 +406,8 @@ ce_dict_destroy( DictionaryCtxt* dict )
} }
if ( !!ctxt->super.bitmaps ) { if ( !!ctxt->super.bitmaps ) {
for ( i = 0; i < nSpecials; ++i ) { for ( i = 0; i < nSpecials; ++i ) {
HBITMAP bitmap = (HBITMAP)ctxt->super.bitmaps[i].largeBM; ceDeleteBitmap( ctxt, ctxt->super.bitmaps[i].largeBM );
if ( !!bitmap ) { ceDeleteBitmap( ctxt, ctxt->super.bitmaps[i].smallBM );
DeleteObject( bitmap );
}
bitmap = (HBITMAP)ctxt->super.bitmaps[i].smallBM;
if ( !!bitmap ) {
DeleteObject( bitmap );
}
} }
XP_FREE( ctxt->super.mpool, ctxt->super.bitmaps ); XP_FREE( ctxt->super.mpool, ctxt->super.bitmaps );
} }