LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

"dynamic memory"

Hello,
 
I have a dynamically allocated array. This array is of structure type. I have a conditional check to verify whether each element of this array was allocated with memory before performing further actions. I have palced the source code below.
 
Initially "ParaStructArray" is allocated with defined array size
ParaStructArray = (T_Data*) calloc(arraysize, sizeof(T_Data));
 
Later in one fo my functions I have the validation check like this
 if(&ParaStructArray[iVal] != NULL)
 {
....
 
Can I know whether there exists any function similar to _msize available in Borlan compiler which can return me the information on the memory size?
 
0 Kudos
Message 1 of 2
(2,879 Views)
1) &ParaStuctArray[iVal] has no reason to be NULL even if calloc failed (ParaStructArray must be NULL if calloc failed)
2) There is no _msize in CVI, but you can write your own. Take a look at the memory 8 bytes before the pointer you just allocated. Be warned that this is compiler/library/version dependant.

Nicolas.
0 Kudos
Message 2 of 2
(2,869 Views)