forked from fl00r/go-tarantool-1.6
-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathalloc.go
More file actions
18 lines (17 loc) · 776 Bytes
/
alloc.go
File metadata and controls
18 lines (17 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package tarantool
// Allocator is an interface for allocating and deallocating byte slices.
type Allocator interface {
// Get returns a pointer to a byte slice of at least the given length.
// The caller should not assume anything about the slice's capacity.
//
// If the allocator cannot allocate a buffer (e.g., invalid length), it
// returns nil. The caller must handle this case appropriately.
Get(length int) *[]byte
// Put returns a byte slice to the allocator for reuse.
// After calling Put, the caller must not use the slice.
//
// The caller must ensure that the slice length remains unchanged between
// Get and Put calls. Modifying the slice length before calling Put may
// prevent the allocator from properly reusing the buffer.
Put(buf *[]byte)
}