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: 

How to work with realloc function in CVI. When i am trying to reallocate structure,It is returning NULL value.

How to work with realloc function in CVI. When i am trying to reallocate structure,It is returning NULL value.

 

separatedVal =  realloc( separatedVal ,(i+1) * sizeof(struct Separate));

 

here i am getting separatedVal = NULL 

0 Kudos
Message 1 of 2
(3,684 Views)

This is the expected behaviour in case realloc cannot allocate the needed space or in case requested size is 0. I suggest you to place a breakpoint on realloc line ans examine the value of 'i': if it's -1 resulting size will be 0 and the allocated memory pointed to by separatedVal will be freed.

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(3,681 Views)