Hi
It seems that I have a problem with the memory handling. Everything works but stops after several iterations with the code 0xc0000005. I have two 2D vectors, I am allocating the memory for the pointer to them, do the calculation, returning the result, freeing the memory. It works for ~15 iterations, and then I get the error. Could someone see the problem?
where exactly does it crash in the debugger?
like 36 seems likely.
why is this memory dynamic?
when you hard code the sizes, use an array. you are making a headache for yourself.
what is nvrtx? Number of vertex? It isn't being used. Should you malloc this value instead of 8 or 3 or something??
wordy return (not a bug, just wordy).
why not
return (dd<1E-6);
Thanks for your comments. I found the error accidently in the different part of the code. I was confused as I thought it is a memory related error and it must be related with the dynamic memory and this code is the only part where I use it.
It is dynamic because the function which I want to use uses the dynamic memory/pointers, so I need to adjust my code to that. I am beginner, and I have some sort of troubles when I use the array, I find vectors much more convenient. The whole code will be updated reg things you mentioned, it is just as it is due to my naive trying to adapt it to my other code.
I am beginner, and I have some sort of troubles when I use the array, I find vectors much more convenient.
Why aren't you using vectors, then?
You're probably corrupting the heap at some point in the execution of the main logic by writing outside the bounds of an array, which causes the implementation of malloc() and free() to get confused and crash. The code that causes that corruption could be anywhere in the program; it's not necessarily here just because it was here that it crashed.
yes, anyone using ** as a parameter to a function has created a monster. The ways around avoiding it are not always worth it.
however consider making your pointers static and allocate them once if you call the function a lot of times. That function spends 90% of its time doing memory stuff, so if you get into this kind of problem where performance matters, find a way to avoid the constant allocation / free cycle.