Browse Source

fix crash in whowas circular buffer

tags/v0.1.0
Jeremy Latt 10 years ago
parent
commit
cab21782b4
2 changed files with 7 additions and 7 deletions
  1. 1
    1
      irc/constants.go
  2. 6
    6
      irc/whowas.go

+ 1
- 1
irc/constants.go View File

@@ -1,7 +1,7 @@
1 1
 package irc
2 2
 
3 3
 const (
4
-	SEM_VER       = "ergonomadic-1.4.2"
4
+	SEM_VER       = "ergonomadic-1.4.3"
5 5
 	CRLF          = "\r\n"
6 6
 	MAX_REPLY_LEN = 512 - len(CRLF)
7 7
 

+ 6
- 6
irc/whowas.go View File

@@ -2,8 +2,8 @@ package irc
2 2
 
3 3
 type WhoWasList struct {
4 4
 	buffer []*WhoWas
5
-	start  uint
6
-	end    uint
5
+	start  int
6
+	end    int
7 7
 }
8 8
 
9 9
 type WhoWas struct {
@@ -26,9 +26,9 @@ func (list *WhoWasList) Append(client *Client) {
26 26
 		hostname: client.hostname,
27 27
 		realname: client.realname,
28 28
 	}
29
-	list.end = (list.end + 1) % uint(len(list.buffer))
29
+	list.end = (list.end + 1) % len(list.buffer)
30 30
 	if list.end == list.start {
31
-		list.start = (list.end + 1) % uint(len(list.buffer))
31
+		list.start = (list.end + 1) % len(list.buffer)
32 32
 	}
33 33
 }
34 34
 
@@ -46,10 +46,10 @@ func (list *WhoWasList) Find(nickname Name, limit int64) []*WhoWas {
46 46
 	return results
47 47
 }
48 48
 
49
-func (list *WhoWasList) prev(index uint) uint {
49
+func (list *WhoWasList) prev(index int) int {
50 50
 	index -= 1
51 51
 	if index < 0 {
52
-		index += uint(len(list.buffer))
52
+		index += len(list.buffer)
53 53
 	}
54 54
 	return index
55 55
 }

Loading…
Cancel
Save