From 8e72579e7c176c39a398a1b64dfc6ba7e763aa90 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 23 Aug 2023 14:50:01 +0200 Subject: [PATCH] core/types: add comment about buffer reuse --- core/types/hashing.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/types/hashing.go b/core/types/hashing.go index e127855ca8..9a6a80ac52 100644 --- a/core/types/hashing.go +++ b/core/types/hashing.go @@ -38,10 +38,11 @@ var encodeBufferPool = sync.Pool{ New: func() interface{} { return new(bytes.Buffer) }, } -// getPooledBuffer retrieves a buffer from the pool and creates a byte slice -// of the requested size from it. +// getPooledBuffer retrieves a buffer from the pool and creates a byte slice of the +// requested size from it. // -// The caller should return the Buffer object back into encodeBufferPool after use! +// The caller should return the *bytes.Buffer object back into encodeBufferPool after use! +// The returned byte slice must not be used after returning the buffer. func getPooledBuffer(size uint64) ([]byte, *bytes.Buffer, error) { if size > math.MaxInt { return nil, nil, fmt.Errorf("can't get buffer of size %d", size)