github.com/outcaste-io/ristretto@v0.2.3/z/calloc_nojemalloc.go (about)

     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  // +build !jemalloc !cgo
     6  
     7  package z
     8  
     9  import (
    10  	"fmt"
    11  )
    12  
    13  // Provides versions of Calloc, CallocNoRef, etc when jemalloc is not available
    14  // (eg: build without jemalloc tag).
    15  
    16  // Calloc allocates a slice of size n.
    17  func Calloc(n int, tag string) []byte {
    18  	return make([]byte, n)
    19  }
    20  
    21  // CallocNoRef will not give you memory back without jemalloc.
    22  func CallocNoRef(n int, tag string) []byte {
    23  	// We do the add here just to stay compatible with a corresponding Free call.
    24  	return nil
    25  }
    26  
    27  // Free does not do anything in this mode.
    28  func Free(b []byte) {}
    29  
    30  func Leaks() string { return "Leaks: Using Go memory" }
    31  func StatsPrint() {
    32  	fmt.Println("Using Go memory")
    33  }
    34  
    35  // ReadMemStats doesn't do anything since all the memory is being managed
    36  // by the Go runtime.
    37  func ReadMemStats(_ *MemStats) { return }