[R-SIG-Mac] Memory length in C
Thomas Lumley
tlumley at u.washington.edu
Mon Oct 4 17:34:24 CEST 2004
On Mon, 4 Oct 2004, Maartje Raijmakers wrote:
>
>
> I suspect memory problems. Therefore I want to do the following, but I don't
> know how:
>
> I use C - routines which I call from R with .C (and C routines that are
> called from fortran by lsoda in the odesolve package)
> One of these C routines has as an argument a pointer to an array of doubles.
>
> Now, I want to check the length of this array within the C-routine.
> Does anyone know how I should do that?
>
You can't. The C pointer doesn't contain any information about the length
of the array -- it has to be passed in as a separate argument.
To detect errors in the length of the array you can put extra entries on
the end of the array and see if they are overwritten.
-thomas
More information about the R-SIG-Mac
mailing list