calloc_nojemalloc.go 998 B

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