Re: Fatal internal error:memory.cpp,line 593

2004-03-09 Thread wewe
typedef struct {
long dimSizes[2];
double Numeric[1];
} TD8;
typedef TD8 **TD8Hdl;

TD8Hdl *spec_map;

DSSetHandleSize(*spec_map, sizeof(int32)*2 + 100*10*sizeof(double) );

Greg could you please explain what is wrong with this because i am
still getting an exception error.



Re: Fatal internal error:memory.cpp,line 593

2004-03-09 Thread Greg McKaskle
 typedef struct {
   long dimSizes[2];
   double Numeric[1];
   } TD8;
 typedef TD8 **TD8Hdl;
 
 TD8Hdl *spec_map;
 
 DSSetHandleSize(*spec_map, sizeof(int32)*2 + 100*10*sizeof(double) );
 
 Greg could you please explain what is wrong with this because i am
 still getting an exception error.

You are only giving a small snippet of code, but it looks like you have 
a variable, spec_map with an uninitialized value.  When calling 
DSSetHandleSize, you are dereferencing this variable and you are 
probably crashing right there, before you even make the function call. 
And if you get lucky and the value is able to be dereferenced, the DSSet 
function will be asked to resize a nonexistant handle and will hopefully 
return an error that the argument is invalid.

To allocate a handle, you use DSNewHandle which is used as *spec_map= 
DSNewHandle(size);

Normally you would be given a param where the handle is already 
allocated and just needs to be resized.  In that case, use the 
SetHandleSize.

Greg McKaskle




Re: Fatal internal error:memory.cpp,line 593

2004-03-03 Thread Greg McKaskle
 typedef struct {
   long dimSize;
   double elt[1];
   } TD3;
 typedef TD3 **TD3Hdl;
 
 TD3Hdl *Tach
 
 noErr = NumericArrayResize(fD, 1, Tach, 8);
 
 ..
 
 It does not compile i get the following error:-
 
 error C2664: 'NumericArrayResize' : cannot convert parameter 3 from
 'TD3 ***  ' to 'unsigned char ***  '
 

Just as with malloc, it isn't odd to need to cast to get from the 
allocation to the pointer where it is stored.

You do want to use NumericArrayResize or DSNewHandle/DSSetHandleSize 
functions.  The DS functions take void and don't typically need casting, 
but the NumericResize apparently does.

I don't have the documentation in front of me, but if you make a local 
with value of zero/null, and pass the address of the local into 
NumericArrayResize, it should work fine.  Make sure to either assign the 
handle into something given to LV or to dispose of it yourself.

Greg McKaskle




Re: Fatal internal error:memory.cpp,line 593

2004-03-02 Thread Robert M
Hello wewe,

At first glance it looks like your memory error may have something to
do with your for loop that it initializing elt[i] =3D 0.  When you
define that struct, you set elt as a single element array.  In the for
loop, you are trying to access 500 elements of that array.  You are
indexing out of that array and probably setting all the memory after
it to 0.

Hope this helps.  If not, let me know, and I=92d be happy to look
further into it.

Have a nice day!

Robert M
Applications Engineer
National Instruments



Fatal internal error:memory.cpp,line 593

2004-03-01 Thread wewe
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; i500; 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