Skip to content

Commit 3bb3583

Browse files
committed
fix(pbuf): wrong pointer
1 parent e231feb commit 3bb3583

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pbuf/pooler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"io"
66
"reflect"
7+
"unsafe"
78
)
89

910
// UserBuffer with customizable user data structure inside.
@@ -18,6 +19,7 @@ func (bufpooler[USRDAT]) New(config any, pooled UserBuffer[USRDAT]) UserBuffer[U
1819
switch c := config.(type) {
1920
case int:
2021
pooled.Grow(c)
22+
*(*[]byte)(unsafe.Pointer(&pooled.Buffer)) = pooled.Bytes()[:c]
2123
if c != pooled.Len() {
2224
panic("unexpected bad buffer Grow")
2325
}

0 commit comments

Comments
 (0)