mirror of
https://github.com/fumiama/orbyte.git
synced 2026-06-05 02:00:30 +08:00
fix(pbuf): wrong pointer
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"io"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// UserBuffer with customizable user data structure inside.
|
||||
@@ -18,6 +19,7 @@ func (bufpooler[USRDAT]) New(config any, pooled UserBuffer[USRDAT]) UserBuffer[U
|
||||
switch c := config.(type) {
|
||||
case int:
|
||||
pooled.Grow(c)
|
||||
*(*[]byte)(unsafe.Pointer(&pooled.Buffer)) = pooled.Bytes()[:c]
|
||||
if c != pooled.Len() {
|
||||
panic("unexpected bad buffer Grow")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user