1 // Copyright 2020 The LevelDB-Go and Pebble Authors. All rights reserved. Use
2 // of this source code is governed by a BSD-style license that can be found in
3 // the LICENSE file.
4 5 //go:build !jemalloc || !cgo
6 // +build !jemalloc !cgo
7 8 package z
9 10 import (
11 "fmt"
12 )
13 14 // Provides versions of Calloc, CallocNoRef, etc when jemalloc is not available
15 // (eg: build without jemalloc tag).
16 17 // Calloc allocates a slice of size n.
18 func Calloc(n int, tag string) []byte {
19 return make([]byte, n)
20 }
21 22 // CallocNoRef will not give you memory back without jemalloc.
23 func CallocNoRef(n int, tag string) []byte {
24 // We do the add here just to stay compatible with a corresponding Free call.
25 return nil
26 }
27 28 // Free does not do anything in this mode.
29 func Free(b []byte) {}
30 31 func Leaks() string { return "Leaks: Using Go memory" }
32 func StatsPrint() {
33 fmt.Println("Using Go memory")
34 }
35 36 // ReadMemStats doesn't do anything since all the memory is being managed
37 // by the Go runtime.
38 func ReadMemStats(_ *MemStats) {}
39