Fix segments list having a greater length than capacity

This commit is contained in:
Zoe Roux 2024-04-01 17:25:47 +02:00
parent 7d423bb049
commit 0c387fc19a
No known key found for this signature in database
2 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package src
import (
"cmp"
"encoding/json"
"fmt"
"io"
@ -167,7 +168,7 @@ func OrNull(str string) *string {
return &str
}
func Max(x, y uint32) uint32 {
func Max[T cmp.Ordered](x, y T) T {
if x < y {
return y
}

View File

@ -68,7 +68,7 @@ func NewStream(file *FileStream, handle StreamHandle, ret *Stream) {
ret.heads = make([]Head, 0)
length, is_done := file.Keyframes.Length()
ret.segments = make([]Segment, length, 2000)
ret.segments = make([]Segment, length, Max(length, 2000))
for seg := range ret.segments {
ret.segments[seg].channel = make(chan struct{})
}