curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

RE: Question/proposal about function returning pollfds from multi handle

From: Daniel Stenberg via curl-library <curl-library_at_lists.haxx.se>
Date: Mon, 18 Dec 2023 16:40:02 +0100 (CET)

On Thu, 14 Dec 2023, Dmitry Karpov via curl-library wrote:

> Probably, it would make sense to also return the count of descriptors, like:
>
> CURLMcode curl_multi_pollfds(struct curl_waitfd *ufds, unsigned int size,
> unsigned int* fd_count);
>
> The fd_count will tell the client code how many descriptors the multi-handle actually has.

How about this tweak:

  CURLMcode
  curl_multi_pollfds(struct Curl_multi *multi,
                     struct curl_waitfd **ufds,
                     unsigned int *fd_count);

It returns a pointer to an array of descriptors and fd_count is the number of
entries in that array. The array is allocated by libcurl and is stored
associated with the multi handle so it is freed with the handle. Calling this
function several times will then just overwrite the same array so it does not
have to get reallocated, unless it needs to grow, during a program's lifetime.

It seems less complicated than having the caller pass in an array of a size it
can't know how big it needs to be. The downside is of course that the data in
the array will not survive calling the function again.

-- 
  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://curl.se/support.html
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2023-12-18