curl-library
Re: Duplicated initialization in singlesocket?
Date: Sun, 3 Jan 2010 14:25:05 +0100
On Sun, Jan 3, 2010 at 12:48 PM, Kamil Dudka <kdudka_at_redhat.com> wrote:
> On Sunday 03 of January 2010 02:12:46 Julien Chaffraix wrote:
>> memset(&socks, 0, sizeof(socks));
>> for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++)
>> socks[i] = CURL_SOCKET_BAD;
>
> I think this may be cruft left over from revision 1.118 when it seemed
> like this:
>
> memset(¤t, 0, sizeof(current));
> for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++)
> current.socks[i] = CURL_SOCKET_BAD;
>
>> My understanding is that the memset does not initialize more than the
>> for loop, which means that it could be dropped - looking at the code
>> there is no use of memset with negative values so I guess there may be
>> some portability issues with using memset(&socks, CURL_SOCKET_BAD,
>> sizeof(socks)). Is my analysis correct?
>
> I think so. The call of memset may be safely removed without any change
> of behavior, right?
I have tested the change and I saw no regression on my machine so I
think it can be safely removed (I was just wondering if there was any
C magic going on in those lines that I did not understand).
Thanks for the answer.
Regards,
Julien
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-01-03