mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
fix crash in whowas circular buffer
This commit is contained in:
parent
142bf3d3bb
commit
cab21782b4
@ -1,7 +1,7 @@
|
|||||||
package irc
|
package irc
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SEM_VER = "ergonomadic-1.4.2"
|
SEM_VER = "ergonomadic-1.4.3"
|
||||||
CRLF = "\r\n"
|
CRLF = "\r\n"
|
||||||
MAX_REPLY_LEN = 512 - len(CRLF)
|
MAX_REPLY_LEN = 512 - len(CRLF)
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ package irc
|
|||||||
|
|
||||||
type WhoWasList struct {
|
type WhoWasList struct {
|
||||||
buffer []*WhoWas
|
buffer []*WhoWas
|
||||||
start uint
|
start int
|
||||||
end uint
|
end int
|
||||||
}
|
}
|
||||||
|
|
||||||
type WhoWas struct {
|
type WhoWas struct {
|
||||||
@ -26,9 +26,9 @@ func (list *WhoWasList) Append(client *Client) {
|
|||||||
hostname: client.hostname,
|
hostname: client.hostname,
|
||||||
realname: client.realname,
|
realname: client.realname,
|
||||||
}
|
}
|
||||||
list.end = (list.end + 1) % uint(len(list.buffer))
|
list.end = (list.end + 1) % len(list.buffer)
|
||||||
if list.end == list.start {
|
if list.end == list.start {
|
||||||
list.start = (list.end + 1) % uint(len(list.buffer))
|
list.start = (list.end + 1) % len(list.buffer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,10 +46,10 @@ func (list *WhoWasList) Find(nickname Name, limit int64) []*WhoWas {
|
|||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
func (list *WhoWasList) prev(index uint) uint {
|
func (list *WhoWasList) prev(index int) int {
|
||||||
index -= 1
|
index -= 1
|
||||||
if index < 0 {
|
if index < 0 {
|
||||||
index += uint(len(list.buffer))
|
index += len(list.buffer)
|
||||||
}
|
}
|
||||||
return index
|
return index
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user