02-15-2011 11:54 AM
I want to use a dynamically allocated memory in a call to DAQmxWriteAnalogF64.
float64 *data = malloc( dataPoints );
...
...
The call works as expected but I am not able to free the memory without an error. Even after the task is stopped and cleared I cannot clean up the allocated memory.
DAQmxStopTaks( taskHandle );
DAQmxClearTask( taskHandle );
if( data )
{
free(data); // causes error
}
Solved! Go to Solution.
02-15-2011 01:51 PM
Hi Chris_c++,
Can you show your code for filling in the data buffer and passing it to DAQmxWriteAnalogF64? If you write past the end of the buffer, the C runtime library's memory allocator may crash or terminate the application with a runtime error when you call free(). My guess is that you really need to allocate dataPoints * sizeof(float64) bytes, not dataPoints bytes.
Brad
02-15-2011 02:39 PM
Hi Brad,
My mistake. You are correct.
Thank you for the response!