-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrm_disable.go
More file actions
94 lines (72 loc) · 1.73 KB
/
Copy pathrm_disable.go
File metadata and controls
94 lines (72 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//go:build disable_rm
package gomem
import (
"io"
"slices"
)
type RecyclableMemory struct {
Memory
}
func NewRecyclableMemory(allocator *ScalableMemoryAllocator) RecyclableMemory {
return RecyclableMemory{}
}
func (r *RecyclableMemory) Clone() RecyclableMemory {
return RecyclableMemory{
Memory: Memory{
Buffers: slices.Clone(r.Buffers),
Size: r.Size,
},
}
}
func (r *RecyclableMemory) InitRecycleIndexes(max int) {
}
func (r *RecyclableMemory) GetAllocator() *ScalableMemoryAllocator {
return nil
}
func (r *RecyclableMemory) SetAllocator(allocator *ScalableMemoryAllocator) {
}
func (r *RecyclableMemory) Recycle() {
}
func (r *RecyclableMemory) NextN(size int) (memory []byte) {
memory = make([]byte, size)
r.PushOne(memory)
return memory
}
func (r *RecyclableMemory) AddRecycleBytes(b []byte) {
r.PushOne(b)
}
type MemoryAllocator struct {
Size int
}
func (*MemoryAllocator) GetBlocks() (blocks []*Block) {
return nil
}
type ScalableMemoryAllocator struct {
}
func NewScalableMemoryAllocator(size int) (ret *ScalableMemoryAllocator) {
return nil
}
func (*ScalableMemoryAllocator) Malloc(size int) (memory []byte) {
return make([]byte, size)
}
func (*ScalableMemoryAllocator) FreeRest(mem *[]byte, keep int) {
if m := *mem; keep < len(m) {
*mem = m[:keep]
}
}
func (*ScalableMemoryAllocator) GetChildren() []*MemoryAllocator {
return nil
}
func (*ScalableMemoryAllocator) Read(reader io.Reader, n int) (mem []byte, err error) {
mem = make([]byte, n)
n, err = reader.Read(mem)
return mem[:n], err
}
func (*ScalableMemoryAllocator) Borrow(size int) (memory []byte) {
return make([]byte, size)
}
func (*ScalableMemoryAllocator) Recycle() {
}
func (*ScalableMemoryAllocator) Free(mem []byte) bool {
return true
}