I need some help.

Can some please explain what i am doing wrong here.  i have created a
Dll from a LV 7.0 vi.  The header file looks something like this:

typedef struct {
        long dimSize;
        double elt[1];
        } TD2;
typedef TD2 **TD2Hdl;

typedef struct {
        double f0;
        double df;
        TD2Hdl magnitude;
        } TD1;

void __cdecl Spectrum(double freq, double amp, TD1 *Spec);

And i have the following code where i allocate memory and attempt to
call 'Spectrum':-

  TD1 *Power;
  double frequency=10, amplitude=1;
  Power = (TD1 *) malloc(sizeof(TD1));
  (*Power).magnitude = (TD2**)malloc(sizeof(TD2));
  *(*Power).magnitude = (TD2*)malloc(5000*sizeof(TD2));

  (*Power->magnitude)->dimSize = 5000;

  for (i=0; i<500; i++) {
          (*Power->magnitude)->elt[i] = 0;
  }

  Spectrum(frequency, amplitude, Power);

I keep getting Fatal internal error: "memory.cpp", line 593" when it
tries to call Spectrum.  I believe i have allocated memory correctly
although i may be wrong.  (I was getting 'exception' errors before).
The VI i used to create the Dll contains a basic 'Function Generator'
(sine wave) and a 'Power Spectrum'.
I have looked at the Knowledge base and dll examples that come with LV
7.0 and have tried setCINArray and NumericArrayResize but have not had
any luck.  It seems like the documentation is for LV 6.0 and 6.1.

Has anybody seen this or have any idea why i am getting this?

Thanks

Reply via email to