Skip to content
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

is there a way to change default "malloc function"? #32

Open
iowrite opened this issue Nov 4, 2021 · 2 comments
Open

is there a way to change default "malloc function"? #32

iowrite opened this issue Nov 4, 2021 · 2 comments

Comments

@iowrite
Copy link

iowrite commented Nov 4, 2021

i want to use the lib in mcu( Inconvenient to use malloc and free), i find it only only can register "free function" useing your api.

@fragglet
Copy link
Owner

fragglet commented Nov 4, 2021

It's a reasonable feature request, the problem is that the individual files are intended to be used standalone with no external dependencies. A few ideas:

  • If you're cherrypicking individual files, you can just modify them to use whatever malloc/free you want
  • If you're using it through the library, it would be a nice feature to be able to add hooks. This could be done via a special #define that only gets defined when the library is compiled; that would import a special header that redefines malloc/free to use alternative versions that are internal to the library.

@iowrite
Copy link
Author

iowrite commented Nov 5, 2021

It's a reasonable feature request, the problem is that the individual files are intended to be used standalone with no external dependencies. A few ideas:

* If you're cherrypicking individual files, you can just modify them to use whatever `malloc`/`free` you want

* If you're using it through the library, it would be a nice feature to be able to add hooks. This could be done via a special `#define` that only gets defined when the library is compiled; that would import a special header that redefines `malloc`/`free` to use alternative versions that are internal to the library.

thank you. I prefer second way.

@iowrite iowrite closed this as completed Nov 5, 2021
@fragglet fragglet reopened this Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants