[gcompris-devel] [PATCH] Initialize the new GcomprisProperties with zeros

Peter Ujfalusi peter.ujfalusi at gmail.com
Wed Jan 26 09:26:04 UTC 2011


Hi,

On Wed, Jan 26, 2011 at 10:43 AM, Marat Buharov <marat.buharov at gmail.com> wrote:
> May be calloc will be more useful instead of malloc+memset?

Yes, you are right, it is more elegant:
-  tmp = (GcomprisProperties *) malloc (sizeof (GcomprisProperties));
+  tmp = (GcomprisProperties *) calloc (1, sizeof (GcomprisProperties));

I've included the v2 patch, since I'm at work, and can not send patches with
git send-email.

Thank you,
Peter

> --
>
> С уважением,
> Бухаров Марат
>
>
>
> On Wed, Jan 26, 2011 at 07:49, Peter Ujfalusi <peter.ujfalusi at gmail.com> wrote:
>> gc_prop_new uses malloc to allocate the GcomprisProperties.
>> Since malloc does not initialize the allocated memory, we
>> need to make sure, that it is initialized correctly.
>> Use memset to fill the allocated memory with zero.
>>
>> Signed-off-by: Peter Ujfalusi <peter.ujfalusi at gmail.com>
>> ---
>> Hello,
>>
>> this patch fixes the problem that I have on 64bit machine:
>> No cursor visible after starting GCompris.
>> I have traced it down, and the tmp->nocursor was TRUE right
>> after the malloc call.
>>
>> The patch is generated agains the git master.
>>
>> PS: I'm not sure about the patch sending protocol for
>> GCompris, but I suppose git send-email shall be fine...
>>
>> Br,
>> Peter
>>
>>  src/gcompris/properties.c |    1 +
>>  1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/gcompris/properties.c b/src/gcompris/properties.c
>> index 29e43dd..0cd18cf 100644
>> --- a/src/gcompris/properties.c
>> +++ b/src/gcompris/properties.c
>> @@ -144,6 +144,7 @@ gc_prop_new ()
>>   GcomprisProperties *tmp;
>>
>>   tmp = (GcomprisProperties *) malloc (sizeof (GcomprisProperties));
>> +  memset (tmp, 0, sizeof (GcomprisProperties));
>>   tmp->music            = 1;
>>   tmp->fx               = 1;
>>   tmp->fullscreen       = 1;
>> --
>> 1.7.4.rc2
>>
>>
>> ------------------------------------------------------------------------------
>> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
>> Finally, a world-class log management solution at an even better price-free!
>> Download using promo code Free_Logger_4_Dev2Dev. Offer expires
>> February 28th, so secure your free ArcSight Logger TODAY!
>> http://p.sf.net/sfu/arcsight-sfd2d
>> _______________________________________________
>> gcompris-devel mailing list
>> gcompris-devel at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gcompris-devel
>>
>
> ------------------------------------------------------------------------------
> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
> Finally, a world-class log management solution at an even better price-free!
> Download using promo code Free_Logger_4_Dev2Dev. Offer expires
> February 28th, so secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsight-sfd2d
> _______________________________________________
> gcompris-devel mailing list
> gcompris-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gcompris-devel
>


More information about the Gcompris-devel mailing list