diff options
| author | Simon Glass <[email protected]> | 2025-05-01 07:37:01 -0600 |
|---|---|---|
| committer | Simon Glass <[email protected]> | 2025-05-30 09:49:31 +0100 |
| commit | 97b586695cd80821455ae06ee178c6c8cf759ce6 (patch) | |
| tree | 51e652168f67b87cfc9fd044079d83a2b574ba7f /include | |
| parent | a619c4410956f446510749b6dc3989849616b7a0 (diff) | |
abuf: Add a helper for initing and allocating a buffer
This construct appears in various places. Reduce code size by adding a
function for it.
It inits the abuf, then allocates it to the requested size.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'include')
| -rw-r--r-- | include/abuf.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/abuf.h b/include/abuf.h index 62ff6499a0c..749bb188b0c 100644 --- a/include/abuf.h +++ b/include/abuf.h @@ -171,6 +171,17 @@ void abuf_init_set(struct abuf *abuf, void *data, size_t size); void abuf_init_const(struct abuf *abuf, const void *data, size_t size); /** + * abuf_init_size() - Set up an allocated abuf + * + * Init a new abuf and allocate its size. + * + * @abuf: abuf to set up + * @data: New contents of abuf + * @size: New size of abuf + */ +bool abuf_init_size(struct abuf *buf, size_t size); + +/** * abuf_uninit() - Free any memory used by an abuf * * The buffer must be inited before this can be called. |
