cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: should [out] parameters be optional?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 17 Jun 2009 23:07:18 +0200 (CEST)

On Wed, 17 Jun 2009, Mohun Biswas wrote:

> 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.

I think they've ended up like this because I've considered the returned values
such important data that it should be very rare that users actually wouldn't
want them.

> 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.

This is an example of a function where allowing NULL will only encourage apps
to do wrong and get themself in trouble! If you're going to use select() on
libcurl's file descriptors, you better get them all!

> 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.

I wouldn't mind allowing NULL for (a few of?) them so if you're feeling this
is worth bothering about please go ahead. Just note that we need updated docs
for this change then as well.

Perhaps you could start with presenting what functions and arguments you're
considering.

-- 
  / daniel.haxx.se
Received on 2009-06-17