...
Source file
src/runtime/msize_allocheaders.go
Documentation: runtime
1
2
3
4
5
6
7
8
9
10
11
12 package runtime
13
14
15
16 func roundupsize(size uintptr, noscan bool) (reqSize uintptr) {
17 reqSize = size
18 if reqSize <= maxSmallSize-mallocHeaderSize {
19
20 if !noscan && reqSize > minSizeForMallocHeader {
21 reqSize += mallocHeaderSize
22 }
23
24
25 if reqSize <= smallSizeMax-8 {
26 return uintptr(class_to_size[size_to_class8[divRoundUp(reqSize, smallSizeDiv)]]) - (reqSize - size)
27 }
28 return uintptr(class_to_size[size_to_class128[divRoundUp(reqSize-smallSizeMax, largeSizeDiv)]]) - (reqSize - size)
29 }
30
31 reqSize += pageSize - 1
32 if reqSize < size {
33 return size
34 }
35 return reqSize &^ (pageSize - 1)
36 }
37
View as plain text