calloc_nojemalloc.go 977 B

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