help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: R: invoking the correct memory management from C files


From: Peter L. Soendergaard
Subject: Re: R: invoking the correct memory management from C files
Date: Wed, 05 May 2010 16:02:20 +0200

ons, 05 05 2010 kl. 13:42 +0000, skrev Riccardo Corradini:
> Could you please show an example?
> 
> 
> 

I my C-library the code typically looks something like this:

void dgtreal_long(....)
{
   LTFAT_COMPLEX *gf = ltfat_malloc(L*sizeof(LTFAT_COMPLEX));

   .. do stuff ...
  
   ltfat_free(gf);
}

If I build it as a standalone library, ltfat_malloc and Ltfat_free are
given by:

void* ltfat_malloc (size_t n)
{
  return fftw_malloc(n);
}

void ltfat_free(void *ptr)
{
  fftw_free(ptr);
}

For Octave I would like to define ltfat_malloc as something like (not
tested!):

void* ltfat_malloc (size_t n)
{ 
  OCTAVE_LOCAL_BUFFER (unsigned char, tmp, n);
  return tmp;
}

Should I just declare ltfat_free to be empty, or is there a better
solution?

Does OCTAVE_LOCAL_BUFFER allocate memory starting a 16 bytes boundaries
(like fftw_malloc) in order to improve performance (both FFTW and ATLAS
can take advantage of this)?

I tried looking at src/mex.cc but it did not make me any wiser.

Cheers,

Peter.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]