github.com/etecs-ru/ristretto@v0.9.1/contrib/demo/node_jemalloc.go (about) 1 //go:build jemalloc && !allocator 2 // +build jemalloc,!allocator 3 4 package main 5 6 import ( 7 "unsafe" 8 9 "github.com/etecs-ru/ristretto/z" 10 ) 11 12 func newNode(val int) *node { 13 b := z.Calloc(nodeSz, "demo") 14 n := (*node)(unsafe.Pointer(&b[0])) 15 n.val = val 16 return n 17 } 18 19 func freeNode(n *node) { 20 buf := (*[z.MaxArrayLen]byte)(unsafe.Pointer(n))[:nodeSz:nodeSz] 21 z.Free(buf) 22 }