fragglet/c-algorithms

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

hellowoad opened this issue · 2 comments

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.

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.

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.