xmalloc_type

Russ Allbery rra at stanford.edu
Tue Aug 13 01:19:51 UTC 2002


I'd like to remove all instances of NEW, COPY, and DISPOSE from the source
tree of CURRENT, replacing them with calls to xmalloc and friends, so that
we can standardize more on a coding style that looks like regular C calls.
I think this is uncontroversial for COPY and DISPOSE, but for NEW the
current macro has a slightly different API that's somewhat more reliable.

NEW takes the type that's being allocated and the number of instances of
that type and returns a pointer cast to that type so that one can more
easily catch type errors.  It's better for allocating structures,
particularly arrays of structures, but not as good for allocating just
flat blobs of memory.

Accordingly, I'd like to introduce xmalloc_type into the source tree that
has the same API as NEW does now, but otherwise looks like the xmalloc
family of macros.  Then I can retire all of the old macros

Does this sound like a good idea to everyone?  Opinions?

-- 
Russ Allbery (rra at stanford.edu)             <http://www.eyrie.org/~eagle/>

    Please send questions to the list rather than mailing me directly.
     <http://www.eyrie.org/~eagle/faqs/questions.html> explains why.


More information about the inn-workers mailing list