On Mon, Dec 01, 2014 at 11:00:11AM -0800, Kevin J. McCarthy wrote:
> In general, mutt checks NULLs pretty well, but returning NULL from
> mutt_substrdup() isn't without risk of just generating a segfault in
> another place.  So personally I would vote for the second or third
> choice.

Returning NULL from something that allocates memory is always a good
(and I dare say the best) option.  It's the standard behavior of all C
standard memory allocators, and if the caller crashes on NULL
dereference, in general you will know EXACTLY where the problem is.
Your function could also make use of errno (setting it for instance to
ENOMEM or EINVAL) to further clarify what actually went wrong.

-- 
Derek D. Martin    http://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail due to spam prevention.  Sorry for the inconvenience.

Attachment: pgp6_sWct6Vzx.pgp
Description: PGP signature

Reply via email to