diff options
author | Joe <rbo@gmx.us> | 2024-01-08 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-01-08 20:20:20 +0100 |
commit | 4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e (patch) | |
tree | 42a8fccdc094212485ca682340d9229e407cd12d /c_lhosts.go | |
parent | tmp (diff) | |
download | hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.tar.gz hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.tar.bz2 hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.tar.xz hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.tar.zst hardflip-4f42a45b5d0454cd1ca5cae2e7ed897bd63f708e.zip |
fix
Diffstat (limited to '')
-rw-r--r-- | c_lhosts.go | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/c_lhosts.go b/c_lhosts.go index fde5881..791e885 100644 --- a/c_lhosts.go +++ b/c_lhosts.go @@ -96,30 +96,28 @@ func (lhost *HostList) add_back(node *HostNode) { lhost.last = last.next } -func (lhost *HostList) reset_id() { - curr := lhost.head - for i := 0; curr != nil; i++ { - curr.ID = i - curr = curr.next - } -} - // removes a host node from the list -func (lhost *HostList) del(id int) { +func (lhost *HostList) del(host *HostNode) { if lhost.head == nil { return } - if lhost.head.ID == id { + if lhost.head == host { lhost.head = lhost.head.next + for curr:= lhost.head; curr != nil; curr = curr.next { + curr.ID -= 1 + } return } curr := lhost.head - for curr.next != nil && curr.next.ID != id { + for curr.next != nil && curr.next != host { curr = curr.next } - if curr.next.ID == id { + if curr.next == host { curr.next = curr.next.next } + for curr := curr.next; curr != nil; curr = curr.next { + curr.ID -= 1 + } } // return the list node with the according id |