diff options
author | Joe <rbo@gmx.us> | 2024-01-09 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-01-09 20:20:20 +0100 |
commit | ba548cbc8e45b931aff88128705deb8116ab35ea (patch) | |
tree | 31a0ba1aafb6fd56bae35385f9f2c9d24ae1733e /c_lhosts.go | |
parent | in progress (diff) | |
download | hardflip-ba548cbc8e45b931aff88128705deb8116ab35ea.tar.gz hardflip-ba548cbc8e45b931aff88128705deb8116ab35ea.tar.bz2 hardflip-ba548cbc8e45b931aff88128705deb8116ab35ea.tar.xz hardflip-ba548cbc8e45b931aff88128705deb8116ab35ea.tar.zst hardflip-ba548cbc8e45b931aff88128705deb8116ab35ea.zip |
delete fixed
Diffstat (limited to '')
-rw-r--r-- | c_lhosts.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/c_lhosts.go b/c_lhosts.go index 74726d8..4041279 100644 --- a/c_lhosts.go +++ b/c_lhosts.go @@ -112,6 +112,15 @@ func (lhost *HostList) del(host *HostNode) { } return } + if lhost.last == host { + ptr := lhost.head + for ptr.next != nil { + ptr = ptr.next + } + lhost.last = ptr + lhost.last.next = nil + return + } ptr := lhost.head for ptr.next != nil && ptr.next != host { ptr = ptr.next @@ -122,13 +131,6 @@ func (lhost *HostList) del(host *HostNode) { for ptr := ptr.next; ptr != nil; ptr = ptr.next { ptr.ID -= 1 } - if lhost.last == host { - ptr := lhost.head - for ptr.next != nil { - ptr = ptr.next - } - lhost.last = ptr - } } // return the list node with the according id |