Closed bmcdonnell-ionx closed 4 years ago
Overriding KISS_FFT_MALLOC
following #28 was not as simple as I'd hoped, since the kissfft source files don't #include
my custom header where I've declared my replacement functions (of course). So not wanting to make any custom changes to the kissfft files, I worked around it by including the c files in my source.
#include "mymalloc_fft.h"
// This source file (C file!) is excluded from the build via project settings.
// We #include it directly here following the KISS_FFT_MALLOC/FREE #defines
// so that we can override its malloc and free.
#include "kiss_fft.c"
void *MyMalloc(size_t size)
{
// ...
}
void MyFree(void *ptr)
{
// ...
}
(In the project settings, KISS_FFT_MALLOC=MyMalloc
and KISS_FFT_FREE=MyFree
.)
Files in kissfft/tools
#include "kiss_fft.h"
, and use functions defined in kiss_fft.c
. Using one of those, if I #include
both .c
files in my one my_malloc_fft.c
file, then kiss_fft.h
gets included twice. Thus the added include guard here in this PR.
In retrospect, #28 lets you override malloc
/free
, but it doesn't "help" you do it. I think the more complete way would be to allow the user to pass in function pointers. However, it looks like I'm not going to wind up using this library in my current project, so it doesn't make sense for me to spend time on that now.
Closing this PR as the submitter moved on and the multiple inclusion only seems to be an issue with "off-label" usage.
The file
_kiss_fft_guts.h
is meant to only be included by the internal .c files of kissfft. Is there any way it could get included multiple times?