[U-Boot] Early malloc() summary

Graeme Russ graeme.russ at gmail.com
Thu Aug 16 13:39:00 CEST 2012


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


More information about the U-Boot mailing list