Re: [CODE] CREATE() buglet

From: d. hall (dhall@OOI.NET)
Date: 07/08/98

>>>>> 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");
        return q;

If malloc is architecture independant when 0 is requested, take that out of
the equations entirely.


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/15/00 PST