-
-
Notifications
You must be signed in to change notification settings - Fork 160
common: implement custom allocator support #3892
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
base: main
Are you sure you want to change the base?
Conversation
Just for future records, this PR is intended to get these issues done:
Initial v1 patch is at: #3859 |
00de6d8
to
321262a
Compare
321262a
to
74d016f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements custom heap allocator support in the ThorVG library, allowing users to provide their own memory allocation functions instead of using the standard library allocators.
- Adds a HeapAllocator struct with function pointers for custom malloc, calloc, realloc, and free implementations
- Updates the Initializer::init() method to accept an optional HeapAllocator parameter
- Replaces direct std library calls with calls through the custom allocator
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
inc/thorvg.h | Defines HeapAllocator struct and updates init() method signature with allocator parameter |
src/common/tvgAllocator.h | Updates memory allocation functions to use custom allocator instead of std library calls |
src/renderer/tvgInitializer.cpp | Stores the provided HeapAllocator in global state during initialization |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
9349d37
to
d2eeb0e
Compare
1187d52
to
a3c338e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@huming2207 I just added comments for aligning the new APIs. Thanks for your contribution.
a3c338e
to
37ce00b
Compare
@hermet Done. Meanwhile should I mark this PR as ready, or should I leave it as draft? |
Hi @hermet
I've just implemented the second version of heap allocator customization support.
I hope it doesn't bring too much trouble to you, but it seems working for me, at least on my PC with the unit test...
I will bring it on to ESP32 with PSRAM-only heap allocator shortly, and see what will happen.
Regards,
Jackson