This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 65fc65342f8bf5fc1415be0d45b0aade0e370a98
Author: zhaoxingyu1 <[email protected]>
AuthorDate: Sat Oct 25 23:48:00 2025 +0800

    lib_tempbuffer: change type char* to void*
    
    The pool hands out raw storage that callers use for arbitrary object
    types, not just strings, so returning char* forced a cast at nearly
    every call site.  Return void* and accept void* on release instead.
    
    The pointer subtraction that derives the pool index now casts to char*
    explicitly, since arithmetic on void* is a compiler extension.
    
    Signed-off-by: zhaoxingyu1 <[email protected]>
---
 include/nuttx/lib/lib.h         | 4 ++--
 libs/libc/misc/lib_tempbuffer.c | 7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/nuttx/lib/lib.h b/include/nuttx/lib/lib.h
index d88fef43087..39d4be5082e 100644
--- a/include/nuttx/lib/lib.h
+++ b/include/nuttx/lib/lib.h
@@ -125,8 +125,8 @@ size_t lib_get_stacksize(size_t size);
 /* Functions defined in lib_tempbuffer.c ************************************/
 
 #ifdef CONFIG_LIBC_TEMPBUFFER
-FAR char *lib_get_tempbuffer(size_t nbytes);
-void lib_put_tempbuffer(FAR char *buffer);
+FAR void *lib_get_tempbuffer(size_t nbytes);
+void lib_put_tempbuffer(FAR void *buffer);
 #else
 #  define lib_get_tempbuffer(n) alloca(n)
 #  define lib_put_tempbuffer(b)
diff --git a/libs/libc/misc/lib_tempbuffer.c b/libs/libc/misc/lib_tempbuffer.c
index 1b8593e96ed..eaba5776aaa 100644
--- a/libs/libc/misc/lib_tempbuffer.c
+++ b/libs/libc/misc/lib_tempbuffer.c
@@ -84,7 +84,7 @@ static struct tempbuffer_s g_tempbuffer =
  *
  ****************************************************************************/
 
-FAR char *lib_get_tempbuffer(size_t nbytes)
+FAR void *lib_get_tempbuffer(size_t nbytes)
 {
   if (nbytes <= TEMP_MAX_SIZE)
     {
@@ -134,9 +134,10 @@ FAR char *lib_get_tempbuffer(size_t nbytes)
  *
  ****************************************************************************/
 
-void lib_put_tempbuffer(FAR char *buffer)
+void lib_put_tempbuffer(FAR void *buffer)
 {
-  int index = (buffer - &g_tempbuffer.buffer[0][0]) / TEMP_MAX_SIZE;
+  int index = ((FAR char *)buffer - &g_tempbuffer.buffer[0][0]) /
+              TEMP_MAX_SIZE;
 
   if (index >= 0 && index < CONFIG_LIBC_MAX_TEMPBUFFER)
     {

Reply via email to