aboutsummaryrefslogtreecommitdiffstats
path: root/src/i_insert.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-04-10 20:20:20 +0200
committerJoe <rbo@gmx.us>2024-04-10 20:20:20 +0200
commit2b184f39542f0ae754a22c36da1d83fe2e3e1a29 (patch)
treeabf8fbac9146e3ca13959647b5ab99a6acfddc46 /src/i_insert.go
parentcool (diff)
downloadhardflip-2b184f39542f0ae754a22c36da1d83fe2e3e1a29.tar.gz
hardflip-2b184f39542f0ae754a22c36da1d83fe2e3e1a29.tar.bz2
hardflip-2b184f39542f0ae754a22c36da1d83fe2e3e1a29.tar.xz
hardflip-2b184f39542f0ae754a22c36da1d83fe2e3e1a29.tar.zst
hardflip-2b184f39542f0ae754a22c36da1d83fe2e3e1a29.zip
fixin segv
Diffstat (limited to 'src/i_insert.go')
-rw-r--r--src/i_insert.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/i_insert.go b/src/i_insert.go
index d9a3e40..f87510d 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -110,17 +110,29 @@ func i_insert_host(data *HardData, insert *HostNode) {
// data.litems.curr.Host.next = insert
// data.litems.curr.Host.next.next = tmp_next
// }
+ var next *ItemsNode = nil
+ if data.litems.curr != nil {
+ next = data.litems.curr.next
+ }
item := &ItemsNode{
0,
nil,
insert,
data.litems.curr,
- data.litems.curr.next,
+ next,
+ }
+ curr := data.litems.curr
+ if curr != nil {
+ curr.next = item
+ if curr.next.next != nil {
+ data.litems.curr.next.next.prev = item
+ }
+ data.litems.curr = data.litems.curr.next
+ } else {
+ data.litems.add_back(item)
+ data.litems.curr = data.litems.head
}
- data.litems.curr.next = item
- data.litems.curr.next.next.prev = item
data.litems.reset_id()
- data.litems.curr = data.litems.curr.next
data.ui.mode = NORMAL_MODE
data.insert = nil
}