xiaoxiang781216 commented on code in PR #7776:
URL: https://github.com/apache/nuttx/pull/7776#discussion_r1041755219


##########
drivers/video/video_framebuff.c:
##########
@@ -114,35 +95,28 @@ void video_framebuff_uninit(video_framebuff_t *fbuf)
 
 int video_framebuff_realloc_container(video_framebuff_t *fbuf, int sz)
 {
-  if (fbuf->vbuf_alloced == NULL || fbuf->container_size != sz)
-    {
-      if (fbuf->container_size != sz)
-        {
-          if (fbuf->vbuf_alloced != NULL)
-            {
-              kmm_free(fbuf->vbuf_alloced);
-            }
+  vbuf_container_t *vbuf;
 
-          fbuf->vbuf_alloced   = NULL;
-          fbuf->container_size = 0;
-        }
-
-      if (sz > 0)
-        {
-          fbuf->vbuf_alloced
-           = (vbuf_container_t *)kmm_malloc(sizeof(vbuf_container_t)*sz);
-          if (fbuf->vbuf_alloced == NULL)
-            {
-              return -ENOMEM;
-            }
-        }
+  if (fbuf->container_size == sz)
+    {
+      return OK;
+    }
 
-      fbuf->container_size = sz;
+  vbuf = kmm_realloc(fbuf->vbuf_alloced, sizeof(vbuf_container_t) * sz);
+  if (vbuf != NULL)
+    {
+      memset(vbuf, 0, sizeof(vbuf_container_t) * sz);
+    }
+  else if (sz != 0)
+    {
+      return -ENOMEM;
     }
 
-  cleanup_container(fbuf);
+  fbuf->vbuf_alloced = vbuf;
+  fbuf->container_size = sz;
 
-  return OK;
+  init_buf_chain(fbuf);
+  return ret;
 }
 
 vbuf_container_t *video_framebuff_get_container(video_framebuff_t *fbuf)

Review Comment:
   ditto



##########
drivers/video/video_framebuff.c:
##########
@@ -114,35 +95,28 @@ void video_framebuff_uninit(video_framebuff_t *fbuf)
 
 int video_framebuff_realloc_container(video_framebuff_t *fbuf, int sz)
 {
-  if (fbuf->vbuf_alloced == NULL || fbuf->container_size != sz)
-    {
-      if (fbuf->container_size != sz)
-        {
-          if (fbuf->vbuf_alloced != NULL)
-            {
-              kmm_free(fbuf->vbuf_alloced);
-            }
+  vbuf_container_t *vbuf;

Review Comment:
   ditto



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to