Repository navigation
Fix memory handling and terminology in UnorderedList section - #1161
Merged
Merged
Conversation
- remove: delete the unlinked node (it leaked on every call), with prose explaining why - Add an UnorderedList destructor, as a listing with explanation and in the full program; note that copying a list is unsafe - search: prose described a `found` flag the code doesn't have - Call pointers "pointers", not "references" (C++ references are a different thing) - Node constructor comment no longer says the data is "the head" - Fix off-by-one line numbers in the remove prose and a Python-style `current.getNext()` Full program verified with `leaks --atExit`: 7 leaked nodes before, 0 after; output unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes in
pretext/LinearLinked/UnorderedListClass.ptx(§4 unordered linked list).Bugs
removeunlinked the node but never freed it, so every call leaked one node. Both the listing and the full program nowdelete current;after relinking, and a new paragraph explains why.~UnorderedList()as its own listing with an explanation (savenextbefore deleting), added it to the full program, and noted briefly that copying a list is now unsafe.Text that contradicted the code
searchprose described afoundflag that the code doesn't have. It now sayssearchreturnstrueimmediately.removeprose's line numbers were off by one (12/13/15 → 13/14/16), and it used a Python-stylecurrent.getNext().Nodeconstructor comment no longer says the data is "set as the head".Testing
I extracted the full ActiveCode program and compiled it with clang++ (C++17,
-Wall -Wextra -fsanitize=undefined). Underleaks --atExit, the original leaks 7 nodes and this version leaks 0. Program output is unchanged.xmllintpasses. I have not done a full PreTeXt build locally.One more PR is coming for each remaining Chapter 4 file (ordered list, Node class, ordered list ADT), plus one for the prefix glossary entry in Chapter 3.
🤖 Generated with Claude Code