From: David Gibson <david@gibson.dropbear.id.au>
To: "Mark A. Greer" <mgreer@mvista.com>
Cc: linuxppc-dev <Linuxppc-dev@ozlabs.org>,
Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH 3/4] powerpc: Add simple memory allocator to bootwrapper
Date: Tue, 10 Oct 2006 16:25:38 +1000 [thread overview]
Message-ID: <20061010062538.GB18681@localhost.localdomain> (raw)
In-Reply-To: <20061010061246.GD28311@mag.az.mvista.com>
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.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
next prev parent reply other threads:[~2006-10-10 6:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-10 6:12 [PATCH 3/4] powerpc: Add simple memory allocator to bootwrapper Mark A. Greer
2006-10-10 6:25 ` David Gibson [this message]
2006-10-10 15:59 ` Mark A. Greer
2006-10-10 12:51 ` Josh Boyer
2006-10-10 16:00 ` Mark A. Greer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061010062538.GB18681@localhost.localdomain \
--to=david@gibson.dropbear.id.au \
--cc=Linuxppc-dev@ozlabs.org \
--cc=mgreer@mvista.com \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).