1
0
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:
源文雨
2025-10-02 14:59:53 +08:00
parent e231feb2d4
commit 3bb358367e

View File

@@ -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")
}