diff options
author | Simon Glass <sjg@chromium.org> | 2021-02-06 09:57:32 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-03-02 15:53:37 -0500 |
commit | 14e46dfb176b4505e4bafa545d3facb9228d40a9 (patch) | |
tree | bac3b3bb1b32f58bccb80c6616bc7d57ca899d7d /include/os.h | |
parent | 869badca616113c7002d934f549bb80f948f9900 (diff) | |
download | u-boot-14e46dfb176b4505e4bafa545d3facb9228d40a9.tar.gz |
sandbox: Add os_realloc()
We provide os_malloc() and os_free() but not os_realloc(). Add this,
following the usual semantics. Also update os_malloc() to behave correctly
when passed a zero size.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'include/os.h')
-rw-r--r-- | include/os.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/include/os.h b/include/os.h index 65bcb232ca..fd010cfee8 100644 --- a/include/os.h +++ b/include/os.h @@ -114,7 +114,7 @@ void os_fd_restore(void); * os_malloc() - aquires some memory from the underlying os. * * @length: Number of bytes to be allocated - * Return: Pointer to length bytes or NULL on error + * Return: Pointer to length bytes or NULL if @length is 0 or on error */ void *os_malloc(size_t length); @@ -128,6 +128,16 @@ void *os_malloc(size_t length); void os_free(void *ptr); /** + * os_realloc() - reallocate memory + * + * This follows the semantics of realloc(), so can perform an os_malloc() or + * os_free() depending on @ptr and @length. + * + * Return: Pointer to reallocated memory or NULL if @length is 0 + */ +void *os_realloc(void *ptr, size_t length); + +/** * os_usleep() - access to the usleep function of the os * * @usec: time to sleep in micro seconds |