>>>>> thus on Tue, 7 Jul 1998 18:23:36 -1000, Dean wrote:
> "d. hall" <dhall@OOI.NET> wrote:
>> Quite a few programmers make wrappers for malloc to one: assert(3) that
>> requested length is > 0, and if the return is non-null. Quite of few
> And this is what CREATE() is, so we should be complete and check for
> num > 0. Values that when cast to signed are negative are another
> issue.
By wrapper, I mean function (inline if need be), not a macro.
Lars Wirzenius and Richard Stevens both have an alloc wrapper.
void *xmalloc(size_t n) {
char *q;
assert(n > 0);
q = malloc(n);
if (q == NULL) {
__publib_error("malloc failed");
exit(EXIT_FAILURE);
}
return q;
}
If malloc is architecture independant when 0 is requested, take that out of
the equations entirely.
d.
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST