diff options
author | Daniel Stenberg <daniel@haxx.se> | 2012-12-23 21:06:40 +0100 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2012-12-23 21:50:14 +0100 |
commit | a1fc9b80c842e74243b6a0e52f2c64e4a96210ce (patch) | |
tree | 3b89901d10b39344971a4f6be6cd47e02ac414ff /lib | |
parent | dfe382c6ae9084093b3f31144a8574fc4cae6bbe (diff) |
curl_multi_wait: avoid an unnecessary memory allocation
Diffstat (limited to 'lib')
-rw-r--r-- | lib/multi.c | 7 |
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; |