Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

huming2207
Copy link
Member

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

@huming2207 huming2207 requested a review from hermet as a code owner October 15, 2025 23:54
@github-actions github-actions bot added APIs Update / Revise APIs renderer Core rendering labels Oct 15, 2025
@huming2207 huming2207 changed the title allocator: implement custom allocator support allocator: implement custom allocator support (v2) Oct 15, 2025
@huming2207
Copy link
Member Author

Just for future records, this PR is intended to get these issues done:

Initial v1 patch is at: #3859

@huming2207 huming2207 force-pushed the feature/custom-allocator-v2 branch from 00de6d8 to 321262a Compare October 16, 2025 00:07
@huming2207 huming2207 changed the title allocator: implement custom allocator support (v2) common: implement custom allocator support (v2) Oct 16, 2025
@huming2207 huming2207 force-pushed the feature/custom-allocator-v2 branch from 321262a to 74d016f Compare October 16, 2025 00:15
@hermet hermet requested a review from Copilot October 16, 2025 03:19
Copy link

@Copilot Copilot AI left a 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.

@hermet hermet added the feature New feature additions label Oct 16, 2025
@hermet hermet marked this pull request as draft October 16, 2025 03:20
@hermet hermet changed the title common: implement custom allocator support (v2) common: implement custom allocator support Oct 16, 2025
@huming2207 huming2207 force-pushed the feature/custom-allocator-v2 branch 2 times, most recently from 9349d37 to d2eeb0e Compare October 16, 2025 03:35
@huming2207 huming2207 force-pushed the feature/custom-allocator-v2 branch from 1187d52 to a3c338e Compare October 16, 2025 22:36
Copy link
Member

@hermet hermet left a 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.

@huming2207 huming2207 force-pushed the feature/custom-allocator-v2 branch from a3c338e to 37ce00b Compare October 20, 2025 06:56
@huming2207
Copy link
Member Author

@hermet Done. Meanwhile should I mark this PR as ready, or should I leave it as draft?

@hermet hermet marked this pull request as ready for review October 20, 2025 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

APIs Update / Revise APIs feature New feature additions renderer Core rendering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants