aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2012-12-23 21:06:40 +0100
committerYang Tse <yangsita@gmail.com>2012-12-23 21:50:14 +0100
commita1fc9b80c842e74243b6a0e52f2c64e4a96210ce (patch)
tree3b89901d10b39344971a4f6be6cd47e02ac414ff
parentdfe382c6ae9084093b3f31144a8574fc4cae6bbe (diff)
curl_multi_wait: avoid an unnecessary memory allocation
-rw-r--r--lib/multi.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/multi.c b/lib/multi.c
index 2905a1346..b3a52d2fe 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -900,7 +900,7 @@ CURLMcode curl_multi_wait(CURLM *multi_handle,
int bitmap;
unsigned int i;
unsigned int nfds = extra_nfds;
- struct pollfd *ufds;
+ struct pollfd *ufds = NULL;
if(!GOOD_MULTI_HANDLE(multi))
return CURLM_BAD_HANDLE;
@@ -929,7 +929,8 @@ CURLMcode curl_multi_wait(CURLM *multi_handle,
easy = easy->next; /* check next handle */
}
- ufds = (struct pollfd *)malloc(nfds * sizeof(struct pollfd));
+ if(nfds)
+ ufds = (struct pollfd *)malloc(nfds * sizeof(struct pollfd));
nfds = 0;
/* Add the curl handles to our pollfds first */
@@ -979,7 +980,7 @@ CURLMcode curl_multi_wait(CURLM *multi_handle,
else
i = 0;
- free(ufds);
+ Curl_safefree(ufds);
if(ret)
*ret = i;
return CURLM_OK;