[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
invoking the correct memory management from C files
From: |
Peter L. Soendergaard |
Subject: |
invoking the correct memory management from C files |
Date: |
Fri, 23 Apr 2010 14:04:16 +0200 |
Hi,
I have created octave-interfaces for the LTFAT project. The interfaces
call the C functions in the LTFAT library. The C functions use a
function like the following to do memory management:
void* ltfat_malloc (size_t n)
{
void *outp;
outp = fftw_malloc(n);
if (outp == NULL)
{
puts("ltfat_malloc failed.");
exit(1);
}
return outp;
}
For the Matlab Mex interfaces I use another straightforward definition:
void* ltfat_malloc(size_t n)
{
return mxMalloc(n);
}
How do I best define ltfat_malloc and friends for use with Octave?
Currently, I call the FFTW functions. Technically, the source file
containing ltfat_malloc is not part of the C-library, so it could be a
C++ file using 'extern "C"' linkage.
Cheers,
Peter.
- invoking the correct memory management from C files,
Peter L. Soendergaard <=