Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slist: rewrite slist_delete() #24

Merged
merged 1 commit into from
May 10, 2016
Merged

Conversation

LeSpocky
Copy link
Collaborator

@LeSpocky LeSpocky commented May 9, 2016

The previous implementation had a serious flaw: the loop used **start as
iteration variable and changed it, so before each return we would have
to make sure it was set exactly right. Now we use a local iteration
variable and only touch **start and **last if necessary.

Additionally the memory of the deleted element is freed now. This was
not done before, but after removing the item from the list, there was no
way to ever release this memory anymore: memory leak!

This should also fix #23.

The previous implementation had a serious flaw: the loop used **start as
iteration variable and changed it, so before each return we would have
to make sure it was set exactly right. Now we use a local iteration
variable and only touch **start and **last if necessary.

Additionally the memory of the deleted element is freed now. This was
not done before, but after removing the item from the list, there was no
way to ever release this memory anymore: memory leak!

The new implementation was tested with unit tests in a personal branch.

Fixes rafaelsteil#23.

Tested-by: Alexander Dahl <[email protected]>
@LeSpocky LeSpocky merged commit de5f422 into rafaelsteil:master May 10, 2016
@LeSpocky LeSpocky deleted the slist branch May 10, 2016 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

slist_delete() updates list pointer to wrong value
1 participant