cURL / Mailing Lists / curl-library / Single Mail

curl-library

should [out] parameters be optional?

From: Mohun Biswas <m_biswas_at_mailinator.com>
Date: Wed, 17 Jun 2009 12:15:50 -0400

Quite a few libcurl functions have so-called [out] parameters, meaning
they can be used to return data. For instance curl_multi_perform:

CURLMcode curl_multi_perform(CURLM *multi_handle, int *running_handles);

is documented to return the number of active handles in
'running_handles'. Many libraries make these optional, meaning you're
allowed to pass NULL if you're not interested in getting that data, but
it seems that libcurl does not do so.

Is this a deliberate style choice or a missing feature? I personally
prefer making them optional because it seems inelegant to allocate
storage (and risk an "unused data" compiler warning) for information you
don't care about.

The case of curl_multi_fdset is particularly confusing because it's
clearly inspired by select(), expecting read/write/exception fd sets.
But select allows any of these to be NULL whereas curl_multi_fdset doesn't.

Anyway, I'm willing to put together a patch if this is a desirable
feature; it shouldn't create any compatibility problem. If you (Daniel)
prefer it the way it is I can certainly live with it, though in that
case I'd be curious to know the reasoning.

Thanks,
MB
Received on 2009-06-17