kostrzewa/tmLQCD — comment on commit c28322a887771987cfa5ddbb056e1365c7b9267a
File:  line 0
By deuzeman:

Ah, of course! Hadn't realized that the conversion was happening -- nice catch! I suppose we should have been using `allocated` there all along anyway, as stated before, and that should fix the segfault in one go.

To be honest, I'm not sure about stack` being an int and being set to -1 anyway. It's ugly and I'll see if I can come up with something more sensible to track that. Suggestions are welcome, of course :).

I didn't really think of setting `stack` and `allocated` to there 0 values, because `finalize_gauge_buffers` will invalidate any further operations on the object anyway by freeing the `reserve` array. It was intended to be used in a way similar to `MPI_finalize`. I guess one could call `initialize_gauge_buffers` again afterwards, but then the values would be reset there.

Nevertheless, calling `free_unused_gauge_buffers` does reduce code duplication and it can't hurt to leave those variables in a consistent state anyway. In fact, I now realize, if I also set `max` to 0 afterwards, then any further operations will give a 'clean' error, rather than a segfault. That certainly makes for better code, so I think I will patch this in tomorrow.

Thanks for having a look at this!