Esempio n. 1
0
func Alloc(x interface{}) {
	trackedMu.Lock()
	defer trackedMu.Unlock()
	if t, ok := tracked[x]; ok {
		panic(fmt.Errorf("double alloc of %#v (originally allocated by %s)", x, t.allocBy))
	}
	tracked[x] = &track{
		x:       x,
		allocBy: debug.Callers(1, 100),
	}
}
Esempio n. 2
0
func Realloc(x interface{}) {
	trackedMu.Lock()
	defer trackedMu.Unlock()
	t, ok := tracked[x]
	if !ok {
		panic(fmt.Errorf("realloc of unknown item %#v", x))
	}
	if t.closed {
		panic(fmt.Errorf("realloc of closed item %#v (allocated by %s)", x, t.allocBy))
	}
	t.allocBy = debug.Callers(1, 100)
}