| 1 | package memory |
| 2 | |
| 3 | import ( |
| 4 | "sync/atomic" |
| 5 | "unsafe" |
| 6 | ) |
| 7 | |
| 8 | func atomicStoreSliceLen(b *[]byte, n int) { |
| 9 | // The mmap keeps data and capacity stable; publish only the length change. |
| 10 | lenp := (*uintptr)(unsafe.Add(unsafe.Pointer(b), unsafe.Sizeof(uintptr(0)))) |
| 11 | atomic.StoreUintptr(lenp, uintptr(n)) |
| 12 | } |