Hello,
does anyone explain me why the 'realloc' (at the second time) throw a runtime error?
thanks.
Printable View
Hello,
does anyone explain me why the 'realloc' (at the second time) throw a runtime error?
thanks.
Your error is here:
Code:
realloc( Val_, sizeof(double) * MC.ValLength_ );
Realloc can move the memory block to a new mem location when extending, if there is not enough room at the current location. You missed the fact that the new address is returned by realloc. Therefore you should have:
Code:
Val_ = (double *)realloc( Val_, sizeof(double) * MC.ValLength_ );