Sunday, October 28, 2012

Qt Transition – Token Lists

There were two lists used to keep a list of allocated tokens and a list of tokens that were deleted multiple times.  These lists were used to detect token memory leaks (tokens not released).  To support this detection, the new and delete operators of the Token structure were overloaded.  In addition to allocating the memory (using regular new), the token was also added to the allocated list.  When deleted, the token was removed from the allocated list.  After processing a line, any tokens still in the allocated list was considered a leak.  Similarly the deleted token list kept track of any tokens that were deleted more than once.

Apparently, the Qt classes (including QList, QLinkedList and QVector) do not interface with overloaded new and delete functions (obscure compiler errors result).  Since another method is now being used to detect memory leaks (valgrind), this detection code is not essential.  The advantage of this code was that it would output the exact tokens that were not released or were deleted twice.  This was nice when the Translator was first implemented and debugged, but now that Translator code is fully working, this level of detail is probably (and hopefully) not necessary.  Therefore, these token lists were removed along with the overloaded new and delete operators.

[commit  d21d3d38ad]

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)