patacongo commented on code in PR #9151:
URL: https://github.com/apache/nuttx/pull/9151#discussion_r1182664319


##########
mm/tlsf/mm_tlsf.c:
##########
@@ -1124,15 +1130,20 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR 
void *oldmem,
 {
   FAR void *newmem;
 
+  /* If oldmem is NULL, then realloc is equivalent to malloc */
+
   if (oldmem == NULL)
     {
       return mm_malloc(heap, size);
     }
 
-  if (size == 0)
+  /* If size is zero, reallocate to the minim size object, so
+   * the memory pointed by oldmem is freed
+   */
+
+  if (size < 1)
     {
-      mm_free(heap, oldmem);
-      return NULL;
+      size = 1;

Review Comment:
   Passing size=0 and size=1 to mm_malloc have the same effect. A minimum chunk 
size is allocated. So I think the above can be removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to