curl_multi_wait: avoid an unnecessary memory allocation
This commit is contained in:
		 Daniel Stenberg
					Daniel Stenberg
				
			
				
					committed by
					
						 Yang Tse
						Yang Tse
					
				
			
			
				
	
			
			
			 Yang Tse
						Yang Tse
					
				
			
						parent
						
							dfe382c6ae
						
					
				
				
					commit
					a1fc9b80c8
				
			| @@ -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,6 +929,7 @@ CURLMcode curl_multi_wait(CURLM *multi_handle, | ||||
|     easy = easy->next; /* check next handle */ | ||||
|   } | ||||
|  | ||||
|   if(nfds) | ||||
|     ufds = (struct pollfd *)malloc(nfds * sizeof(struct pollfd)); | ||||
|   nfds = 0; | ||||
|  | ||||
| @@ -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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user