mirror of
https://github.com/thunderbrewhq/binana.git
synced 2025-12-12 01:42:29 +00:00
chore(binana): update files
This commit is contained in:
parent
1400de8b1f
commit
c30e1199d7
24 changed files with 35645 additions and 4286 deletions
29
go/symfile/memory_table.go
Normal file
29
go/symfile/memory_table.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package symfile
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Most tables are reasonably-sized and can be kept in memory
|
||||
type InMemoryTable struct {
|
||||
Entries []Entry
|
||||
}
|
||||
|
||||
func (t *InMemoryTable) Insert(entry *Entry) (err error) {
|
||||
i := sort.Search(len(t.Entries), func(i int) bool {
|
||||
return t.Entries[i].StartAddress >= entry.StartAddress
|
||||
})
|
||||
|
||||
if i < len(t.Entries) {
|
||||
t.Entries = slices.Insert(t.Entries, i, *entry)
|
||||
} else {
|
||||
t.Entries = append(t.Entries, *entry)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (t *InMemoryTable) Len() int {
|
||||
return len(t.Entries)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue