[PATCH v4 02/15] Add support for an owned buffer
trini at konsulko.com
Sat Oct 9 03:38:08 CEST 2021
On Sat, Sep 25, 2021 at 07:03:07AM -0600, Simon Glass wrote:
> When passing a data buffer back from a function, it is not always clear
> who owns the buffer, i.e. who is responsible for freeing the memory used.
> An example of this is where multiple files are decompressed from the
> firmware image, using a temporary buffer for reading (since the
> compressed data has to live somewhere) and producing a temporary or
> permanent buffer with the resuilts.
> Where the firmware image can be memory-mapped, as on x86, the compressed
> data does not need to be buffered, but the complexity of having a buffer
> which is either allocated or not, makes the code hard to understand.
> Introduce a new 'abuf' which supports simple buffer operations:
> - encapsulating a buffer and its size
> - either allocated with malloc() or not
> - able to be reliably freed if necessary
> - able to be converted to an allocated buffer if needed
> This simple API makes it easier to deal with allocated and memory-mapped
> Signed-off-by: Simon Glass <sjg at chromium.org>
Applied to u-boot/master, thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 659 bytes
Desc: not available
More information about the U-Boot