[MOAB-dev] [Itaps-users] [PATCH 1/2] iMesh_MOAB: do not allocate new memory for count=0 items

Jed Brown jed at 59A2.org
Fri Jun 10 14:21:36 CDT 2011


On Fri, Jun 10, 2011 at 21:14, James Porter <jvporter at wisc.edu> wrote:

> That's not what your patch does, though. I think this sounds like a good
> idea in general (I missed the first email that explained the context),
> but I don't think "never allocate for 0-sized arrays" is the right way.
>

Ah, but it is equivalent. If the user nullified the pointer, then by
definition, they already have a pointer equal to NULL. That is valid to be
passed to free(). If the user had a pointer that was non-NULL, then
(according to our "new" semantics) they didn't want you to allocate
anything.

I can't imagine a use case where the caller would depend on malloc(0)
actually being called (given that either way, they have a pointer that can
be free'd).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/moab-dev/attachments/20110610/fb0852b1/attachment.htm>


More information about the moab-dev mailing list