LCOV - code coverage report
Current view: top level - pebble/internal/cache - entry_invariants.go (source / functions) Hit Total Coverage
Test: 2024-10-03 08:17Z 41145ee9 - tests only.lcov Lines: 11 14 78.6 %
Date: 2024-10-03 08:17:34 Functions: 0 0 -

          Line data    Source code
       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 (invariants && !race) || (tracing && !race)
       6             : // +build invariants,!race tracing,!race
       7             : 
       8             : package cache
       9             : 
      10             : import (
      11             :         "fmt"
      12             :         "os"
      13             : 
      14             :         "github.com/cockroachdb/pebble/internal/invariants"
      15             : )
      16             : 
      17             : // When the "invariants" or "tracing" build tags are enabled, we need to
      18             : // allocate entries using the Go allocator so entry.val properly maintains a
      19             : // reference to the Value.
      20             : const entriesGoAllocated = true
      21             : 
      22           1 : func entryAllocNew() *entry {
      23           1 :         e := &entry{}
      24           1 :         // Note: this is a no-op if invariants and tracing are disabled or race is
      25           1 :         // enabled.
      26           1 :         invariants.SetFinalizer(e, func(obj interface{}) {
      27           1 :                 e := obj.(*entry)
      28           1 :                 if *e != (entry{}) {
      29           0 :                         fmt.Fprintf(os.Stderr, "%p: entry was not freed", e)
      30           0 :                         os.Exit(1)
      31           0 :                 }
      32             :         })
      33           1 :         return e
      34             : }
      35             : 
      36           1 : func entryAllocFree(e *entry) {
      37           1 :         *e = entry{}
      38           1 : }

Generated by: LCOV version 1.14