mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 16:18:48 -05:00
curl_multi_wait: avoid an unnecessary memory allocation
This commit is contained in:
parent
dfe382c6ae
commit
a1fc9b80c8
@ -900,7 +900,7 @@ CURLMcode curl_multi_wait(CURLM *multi_handle,
|
|||||||
int bitmap;
|
int bitmap;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int nfds = extra_nfds;
|
unsigned int nfds = extra_nfds;
|
||||||
struct pollfd *ufds;
|
struct pollfd *ufds = NULL;
|
||||||
|
|
||||||
if(!GOOD_MULTI_HANDLE(multi))
|
if(!GOOD_MULTI_HANDLE(multi))
|
||||||
return CURLM_BAD_HANDLE;
|
return CURLM_BAD_HANDLE;
|
||||||
@ -929,6 +929,7 @@ CURLMcode curl_multi_wait(CURLM *multi_handle,
|
|||||||
easy = easy->next; /* check next handle */
|
easy = easy->next; /* check next handle */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(nfds)
|
||||||
ufds = (struct pollfd *)malloc(nfds * sizeof(struct pollfd));
|
ufds = (struct pollfd *)malloc(nfds * sizeof(struct pollfd));
|
||||||
nfds = 0;
|
nfds = 0;
|
||||||
|
|
||||||
@ -979,7 +980,7 @@ CURLMcode curl_multi_wait(CURLM *multi_handle,
|
|||||||
else
|
else
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
free(ufds);
|
Curl_safefree(ufds);
|
||||||
if(ret)
|
if(ret)
|
||||||
*ret = i;
|
*ret = i;
|
||||||
return CURLM_OK;
|
return CURLM_OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user