Re: class gc and gc_alloc(0, xxx)

Date view Thread view Subject view Author view

From: Godmar Back (gback@cs.utah.edu)
Date: Fri Dec 18 1998 - 18:06:15 EST


>
> Godmar Back writes:
> > > > > - add an assert(size != 0) in gcMalloc().
> > > >
> > > > Yes, I think that's a good course of action.
> > > > I also added an assert if someone attempt to free non-fixed objects.
> > >
> > > It's not clear to me why trying to allocate zero bytes is a bug.
> > > Why not just return NULL in this case?
> >
> > That would fix the mark problem. However at some point, we will want
> > to gracefully handle out of memory conditions. I propose we use NULL
> > for that.
>
> Oh yeah, forgot about that. Then instead we can use a special
> magic value that the walker recognizes (and ignores).
>
> FreeBSD's malloc/free does something akin to this.
>

 As a principle, I believe it's bad programming practice to attempt to
allocate zero bytes, and I would like our allocator to flag such attempts.

        - Godmar


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:57:23 EDT