-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Provide k_realloc() #41151
Comments
Yes, most likely because no one needed it so far.
The low-level heap layer has that. It is However Also, the low-level heap layer already implements Yet, if your memory needs are well characterized, you could create a heap |
Idea was abandoned. |
reopening this issue, as there are use cases that require it |
Please describe those use cases so potential alternatives to It is unfortunate that past discussions were not reflected here. |
The |
Sorry for the delay - I was on vacation.
No, it won't. You simply cannot use any
Of course, one could say that, in the discussion linked above, a realloc |
reopening this issue again, as there is a use cases that require it. hawkBit is currently using zephyr/subsys/mgmt/hawkbit/hawkbit.c Line 858 in c2c95e1
not having a |
As was pointed out upthread, this is mostly just an exercise in forwarding of APIs. Someone needs to:
Neither is more than a few lines of code, and the existing code can be used as a guide. |
Introduction
Problem description
Zephyr provides
k_malloc()
,k_calloc()
andk_free()
but notk_realloc()
. This RFC is about providing it or finding a different solution for the first potential user that is LVGL v8.Background: Zephyr currently uses LVGL v7. I'm working on a changeset that will bump the LVGL version to v8 (link). This version however requires some
realloc()
implementation. Currently lvgl's Kconfig options allow to choose which allocator to use: the kernel heap, the libc implementation or the internal allocator in lvgl.Proposed change
If we want to keep this triple choice then the kernel heap must introduce
k_realloc()
.Detailed RFC
Proposed change (Detailed)
Implement
k_realloc()
that would be the analog of the libc'srealloc()
.The prototype would look like this:
void *k_realloc(void *ptr, size_t size);
Internally it would check if size if bigger than the currently allocated chunk. If yes, it would allocate a new chunk, copy the contents into it, then free the current one. Otherwise it would just return the current pointer.
Dependencies
In linux we have the
ksize()
function that returns the actual size of the allocated block. We'd need some helper like this in zephyr in order to not have to look too deep into the heap code.Concerns and Unresolved Questions
Is there any reason why
k_realloc()
is not already provided in zephyr?Alternatives
Accept that lvgl cannot work with the kernel heap and move on.
The text was updated successfully, but these errors were encountered: