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