summaryrefslogtreecommitdiff
path: root/vendor/modernc.org/memory/memory.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2025-04-01 15:24:11 +0000
committerLibravatar GitHub <noreply@github.com>2025-04-01 16:24:11 +0100
commitfdf23a91de791b813f65c244fd75e3262171f1b0 (patch)
tree6ad5045e17f4520386067e4334e749be09ae1510 /vendor/modernc.org/memory/memory.go
parentadd a security.md stub, until (if) we determine a fancier security process :w... (diff)
downloadgotosocial-fdf23a91de791b813f65c244fd75e3262171f1b0.tar.xz
update modernc.org/sqlite to v1.37.0-concurrrency-workaround (#3958)
Diffstat (limited to 'vendor/modernc.org/memory/memory.go')
-rw-r--r--vendor/modernc.org/memory/memory.go20
1 files changed, 3 insertions, 17 deletions
diff --git a/vendor/modernc.org/memory/memory.go b/vendor/modernc.org/memory/memory.go
index c6d02df80..e25acda9b 100644
--- a/vendor/modernc.org/memory/memory.go
+++ b/vendor/modernc.org/memory/memory.go
@@ -57,7 +57,6 @@ import (
"fmt"
"math/bits"
"os"
- "reflect"
"unsafe"
)
@@ -352,12 +351,7 @@ func (a *Allocator) Calloc(size int) (r []byte, err error) {
return nil, err
}
- var b []byte
- sh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
- sh.Cap = usableSize(p)
- sh.Data = p
- sh.Len = size
- return b, nil
+ return (*rawmem)(unsafe.Pointer(p))[:size:usableSize(p)], nil
}
// Close releases all OS resources used by a and sets it to its zero value.
@@ -396,11 +390,7 @@ func (a *Allocator) Malloc(size int) (r []byte, err error) {
return nil, err
}
- sh := (*reflect.SliceHeader)(unsafe.Pointer(&r))
- sh.Cap = usableSize(p)
- sh.Data = p
- sh.Len = size
- return r, nil
+ return (*rawmem)(unsafe.Pointer(p))[:size:usableSize(p)], nil
}
// Realloc changes the size of the backing array of b to size bytes or returns
@@ -422,11 +412,7 @@ func (a *Allocator) Realloc(b []byte, size int) (r []byte, err error) {
return nil, err
}
- sh := (*reflect.SliceHeader)(unsafe.Pointer(&r))
- sh.Cap = usableSize(p)
- sh.Data = p
- sh.Len = size
- return r, nil
+ return (*rawmem)(unsafe.Pointer(p))[:size:usableSize(p)], nil
}
// UsableSize reports the size of the memory block allocated at p, which must