Look wrote: ↑Fri Jan 26, 2024 6:02 pmI removed the extra frees . Still there seems to be memory leaks.
Then they are in other parts of the code. For example, it could be that you accidentally null some of the pointers somewhere. Besides, what's even the point of that alloc/free cycle? You can simply memset the stuff to 0 if you need a value reset.
Look wrote: ↑Fri Jan 26, 2024 6:02 pmI removed the extra frees . Still there seems to be memory leaks.
Then they are in other parts of the code. For example, it could be that you accidentally null some of the pointers somewhere. Besides, what's even the point of that alloc/free cycle? You can simply memset the stuff to 0 if you need a value reset.
I removed mentioned alloc/free code. Now in pos_set function , this is the crashing part according to debugger:
memset(pos, 0, offsetof(Position, moveList));
memset(st, 0, StateSize); // here
Without the data type declaration, that's impossible to tell, but it could be that these memsets are erroneously nulling some parts, including pointers, that they shouldn't be nulling. That would also explain why it didn't crash with the free, because you are allowed to free a null pointer, and why there's a memory leak.