cURL / Mailing Lists / curl-library / Single Mail

curl-library

Duplicated initialization in singlesocket?

From: Julien Chaffraix <julien.chaffraix_at_gmail.com>
Date: Sun, 3 Jan 2010 02:12:46 +0100

Hi,

I think cURL is initializing a variable twice in singlesocket
(lib/multi.c:1760). The relevant code is inlined below:

curl_socket_t socks[MAX_SOCKSPEREASYHANDLE];
[sip]

memset(&socks, 0, sizeof(socks));
for(i=0; i< MAX_SOCKSPEREASYHANDLE; i++)
    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?

Thanks a lot and 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