From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid Freed with CA_FreeMemory

I'm using Labwindows CVI FDS 10.0

 

Hello, I get the error "Invalid Freed" from the function CA_FreeMemory.

 

First I allocated the memory with:

...

case (CAVT_SHORT | CAVT_ARRAY): 

ConvertirVariant=CA_VariantGet1DArray (&Variant_Item, CAVT_SHORT, &Leer_ASHORT, &Nvalores);
break;

 

Later y want free this memory ...

 

CA_FreeMemory(Leer_ASHORT);

 

and I get the message Invalid : Freed

 

Many Thanks

 

0 Kudos
Message 1 of 2
(4,418 Views)

Hi!

 

Usually, if you get the message invalid: freed it is because you have already freed the pointer before... Just check it out.

Have you verify if CA_VariantGet1DArray  didn't return an error or did not allocate correctly the array?

And finally here it is an extract from the CVI Help about which function you need to use according to the type of array values :

 

C-style array that CA_VariantGet1DArray dynamically allocates. The type of the array must be the same as arrayType. Pass the address of an array pointer.

You can treat this array like any other 1D C array.

Call CA_FreeMemory on the array to discard it when it is no longer needed. If the array contains any of the data types in the following table, you must call the appropriate function to free each element when you finish using it.

Data Type Function to Free Each Element
char * CA_FreeMemory
CAObjHandle CA_DiscardObjHandle
BSTR CA_FreeBSTR
LPUNKNOWN array[i]->lpVtbl->Release()
LPDISPATCH array[i]->lpVtbl->Release()
VARIANT CA_VariantClear

 

 

 

Best regards,

thomas1330

 

0 Kudos
Message 2 of 2
(4,208 Views)