[PATCH 3/4] powerpc: Add simple memory allocator to bootwrapper

Mark A. Greer mgreer at mvista.com
Wed Oct 11 01:59:25 EST 2006


On Tue, Oct 10, 2006 at 04:25:38PM +1000, David Gibson wrote:
> On Mon, Oct 09, 2006 at 11:12:46PM -0700, Mark A. Greer wrote:
> > Provide primitive malloc, free, and realloc functions for bootwrapper.
> 
> [snip]
> > +/*
> > + * Change size of area pointed to by 'ptr' to 'size'.
> > + * If 'ptr' is NULL, then its a malloc().  If 'size' is 0, then its a free().
> > + * 'ptr' must be NULL or a value previously returned by simple_realloc().
> > + */
> > +static void *simple_realloc(void *ptr, unsigned long size)
> > +{
> > +	if (size == 0) {
> > +		simple_free(ptr);
> > +		return NULL;
> > +	}
> > +	else if (ptr == NULL)
> > +		return simple_malloc(size);
> > +	else {
> > +		simple_free(ptr);
> > +		return simple_malloc(size);
> > +	}
> > +}
> 
> Um.. the above is clearly broken, it will throw away the data in a
> realloc()ed block.

Yes, too much of a hurry, I guess.  I'll fix.

Mark



More information about the Linuxppc-dev mailing list