File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -42,11 +42,11 @@ func roundMultiple(n, k uint) uint {
42
42
// POSIX libc's malloc. However, Alloc panics if an error occurs when
43
43
// requesting more memory from the operating system.
44
44
func Alloc (size uint ) unsafe.Pointer {
45
- m .Lock ()
46
- defer m .Unlock ()
47
45
if size == 0 {
48
46
return nil
49
47
}
48
+ m .Lock ()
49
+ defer m .Unlock ()
50
50
// Iterate through linked list of headers.
51
51
p := freep
52
52
for {
@@ -97,11 +97,11 @@ func Alloc(size uint) unsafe.Pointer {
97
97
// However, Free panics if an error occurs when releasing memory to
98
98
// the operating system.
99
99
func Free (p unsafe.Pointer ) {
100
- m .Lock ()
101
- defer m .Unlock ()
102
100
if p == nil {
103
101
return
104
102
}
103
+ m .Lock ()
104
+ defer m .Unlock ()
105
105
h := (* header )(unsafe .Pointer (uintptr (p ) - uintptr (szheader )))
106
106
arcurr := h .arena
107
107
h .allocated = false
You can’t perform that action at this time.
0 commit comments