<div class="gmail_quote">On Fri, Jun 10, 2011 at 19:43, Tim Tautges <span dir="ltr"><<a href="mailto:tautges@mcs.anl.gov">tautges@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I'm fine with at least not allocating for count = 0, and my read of the iMesh spec is that it's silent on this issue.</blockquote><div><br></div><div>It's subtle. The letter of the spec suggests (to me) that if you pass in UNALLOCATED (currently defined using OR), you get a pointer that free() can be called on. This pointer may or may not be NULL (some malloc() implementations return NULL on zero-length allocation, others return a pointer that can be freed). I doubt this was intentional; the zero length case was probably not considered explicitly.</div>
<div><br></div><div>If nobody has a dependency on allocation of zero length returns, I think the wording should just be clarified.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I think we (Jason & I) were for the OR instead of AND (i.e. allocating if either the allocated_length is 0 or the array ptr is NULL) just to avoid the nuisance of having to initialize more stuff. That's not a strong preference though.</blockquote>
</div><br><div>I don't have a strong preference here, but memory allocation and ownership is something that C programmers need to pay attention to. An extra "=0" is not a great burden, especially if it improves semantic clarity.</div>