From mboxrd@z Thu Jan 1 00:00:00 1970 From: Graeme Russ Date: Thu, 16 Aug 2012 21:39:00 +1000 Subject: [U-Boot] Early malloc() summary In-Reply-To: <201208150156.32843.marex@denx.de> References: <201208141437.29415.marex@denx.de> <201208150156.32843.marex@denx.de> Message-ID: <502CDBD4.7090508@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Marek, On 08/15/2012 09:56 AM, Marek Vasut wrote: > Dear Graeme Russ, > > [...] > >> >> Third path is dm_malloc() - Although ugly, it has a few nicities... > > Thinking about dm_malloc() ... if it's entirely different, the semantics can be > adjusted too ... say to "int dm_malloc(void **ptr, size_t size);": > > - return int: error code > - **ptr: pointer to allocated memory, that way we can possibly implement pointer > tracking (of course that'd need more work, might be a debug feature) > - size: size of allocated area I think we should keep the semantics as close as possible to malloc(). If there is an error, return NULL. For starters, if we do later go with a common malloc() which gets wrapped, changing the code will be a lot easier. Regards, Graeme