jingfei195887 commented on code in PR #21439:
URL: https://github.com/apache/nuttx/pull/21439#discussion_r4470127434
##########
fs/inode/fs_files.c:
##########
@@ -175,6 +180,15 @@ static int fdlist_extend(FAR struct fdlist *list, size_t
row)
return OK;
}
+ /* Release the buffers we allocated for any rows that the current list
+ * already supplies (its pointers will be copied in below).
+ */
+
+ for (j = orig_rows; j < i && j < list->fl_rows; j++)
+ {
+ fs_heap_free(fds[j]);
Review Comment:
@casaroli @anchao I think @casaroli is right here, but how about we use
`goto retry ;` when `list->fl_rows != orig_rows` and add a label `retry:` in
line 119, Isn't a `goto` within the function a better choice than recursion?
```
static int fdlist_extend(FAR struct fdlist *list, size_t row)
{
...
retry:
orig_rows = list->fl_rows;
if (row <= orig_rows)
{
return 0;
}
flags = spin_lock_irqsave_notrace(&list->fl_lock);
if (list->fl_rows != orig_rows)
{
spin_unlock_irqrestore_notrace(&list->fl_lock, flags);
for (j = orig_rows; j < row; j++)
{
fs_heap_free(fds[j]);
}
fs_heap_free(fds);
goto retry;
}
memcpy(fds, list->fl_fds, orig_rows * sizeof(FAR struct fd *));
...
}
```
--
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]