Thank you both for the tips.

I guess Noel got it when he said that " The general rule is that you
shouldn't delete pointers returned by Open Babel API calls". That what I
was doing when trying to delete an OBMol object. "Not deleting" solved the
issue.

I consider myself a scientist that programs to solve problems rather than a
programmer, so Geoffrey's tip is gonna be very useful! Thanks for sharing!

All the best,

-Alessandro


Em sáb., 7 de mar. de 2020 às 16:26, Geoffrey Hutchison <
geoff.hutchi...@gmail.com> escreveu:

> I haven't had a chance to test this but it looks like you're deleting
> pointers that you shouldn't be. Only call "delete" if there is a
> corresponding "new". The general rule is that you shouldn't delete pointers
> returned by Open Babel API calls, unless the documentation explicitly
> states that the caller is responsible for freeing the memory. In 99% of
> cases, the pointer is to a data structure that is managed by something
> else. In short, trying commenting out "delete[] xyz".
>
>
>
>  I'd highly recommend anyone writing C++ code to use sanitizer checks in
> GCC and Clang. Useful checks include leak detection, memory errors (like
> this), undefined behavior, etc.:
> https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html
>
> Cheers,
> -Geoff
>


-- 
********************************************************
Alessandro S. Nascimento
Professor
São Carlos Institute of Physics (IFSC)
University of São Paulo (USP)
E-mail: asnascime...@ifsc.usp.br
Phone: +55-16-3373-8709
********************************************************
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to