comparison gui/bitmap.c @ 23200:44cf48083874

Use calloc instead of malloc+memset
author reimar
date Wed, 02 May 2007 16:42:31 +0000
parents e1d0d26f5e3c
children 794aba782ebd
comparison
equal deleted inserted replaced
23199:e1d0d26f5e3c 23200:44cf48083874
72 if ( bf->BPP == 24 ) 72 if ( bf->BPP == 24 )
73 { 73 {
74 tmpImage=bf->Image; 74 tmpImage=bf->Image;
75 bf->ImageSize=bf->Width * bf->Height * 4; 75 bf->ImageSize=bf->Width * bf->Height * 4;
76 bf->BPP=32; 76 bf->BPP=32;
77 if ( ( bf->Image=malloc( bf->ImageSize ) ) == NULL ) 77 if ( ( bf->Image=calloc( 1, bf->ImageSize ) ) == NULL )
78 { 78 {
79 free( tmpImage ); 79 free( tmpImage );
80 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] not enough memory for image\n" ); 80 mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[bitmap] not enough memory for image\n" );
81 return 1; 81 return 1;
82 } 82 }
83 memset( bf->Image,0,bf->ImageSize );
84 for ( c=0,i=0; c < bf->ImageSize; ) 83 for ( c=0,i=0; c < bf->ImageSize; )
85 { 84 {
86 bf->Image[c++]=tmpImage[i++]; //red 85 bf->Image[c++]=tmpImage[i++]; //red
87 bf->Image[c++]=tmpImage[i++]; //green 86 bf->Image[c++]=tmpImage[i++]; //green
88 bf->Image[c++]=tmpImage[i++]; c++; //blue 87 bf->Image[c++]=tmpImage[i++]; c++; //blue