// Dereferencing pointers if not nil
// TODO: Please someone tell me, how to do this right!
961410
func (t *Table) AddP(cols ...interface{}) {
	converted := make([]string, 0, len(cols))
	var str string
	for _, v := range cols {
		if value := reflect.ValueOf(v); value.Kind() == reflect.Ptr {
			indirect := reflect.Indirect(value)
			switch {
			case indirect != reflect.Zero(value.Type()) && indirect.IsValid() == true:
				switch {
				case indirect.Kind() == reflect.String:
					str = fmt.Sprint(indirect.String())
				case indirect.Kind() == reflect.Int:
					str = fmt.Sprint(indirect.Int())
				case indirect.Kind() == reflect.Float32:
					str = fmt.Sprint(indirect.Float())
				case indirect.Kind() == reflect.Bool:
					str = fmt.Sprint(indirect.Bool())
				case indirect.Kind() == reflect.Slice:
					str = fmt.Sprint(v)
				default:
					str = fmt.Sprint(v)
				}
			default:
				str = ""
			}
		} else {
			str = fmt.Sprint(v)
		}
		converted = append(converted, str)
	}
	t.AddStrings(converted)
}
252514
func (p Pointers) Get(i int) bool {
	return p[uint(i)>>ptrShift]&(1<<(uint(i)&ptrModMask)) != 0
}
1084925
func (v *Variable) maybeDereference() *Variable {
	if v.Unreadable != nil {
		return v
	}

	switch t := v.RealType.(type) {
	case *godwarf.PtrType:
		if v.Addr == 0 && len(v.Children) == 1 && v.loaded {
			// fake pointer variable constructed by casting an integer to a pointer type
			return &v.Children[0]
		}
		ptrval, err := readUintRaw(v.mem, uintptr(v.Addr), t.ByteSize)
		r := v.newVariable("", uintptr(ptrval), t.Type, DereferenceMemory(v.mem))
		if err != nil {
			r.Unreadable = err
		}

		return r
	default:
		return v
	}
}
380062
func (s *NestedSort) NestedSort(nestedSort *NestedSort) *NestedSort {
	s.nestedSort = nestedSort
	return s
}
668420
func ParseReferenceParam(paramStr string, info SearchParamInfo) *ReferenceParam {
	if info.Postfix != "" {
		typ := findReferencedType("", info)
		q := Query{Resource: typ, Query: info.Postfix + "=" + paramStr}
		return &ReferenceParam{info, ChainedQueryReference{Type: typ, ChainedQuery: q}}
	} else {
		ref := unescape(paramStr)
		re := regexp.MustCompile("\\/?(([^\\/]+)\\/)?([^\\/]+)$")
		if m := re.FindStringSubmatch(ref); m != nil {
			typ := findReferencedType(m[2], info)
			if u, e := url.Parse(ref); e == nil && u.IsAbs() {
				return &ReferenceParam{info, ExternalReference{Type: typ, URL: ref}}
			} else {
				return &ReferenceParam{info, LocalReference{Type: typ, ID: m[3]}}
			}
		}
	}
	return &ReferenceParam{info, nil}
}
1208668
func (a *Allocation) Ptr() unsafe.Pointer {
	sh := (*reflect.SliceHeader)(unsafe.Pointer(&a.data))
	return unsafe.Pointer(sh.Data)
}
158045
func PointerOver(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "pointerover", Listener: listener}
}
950265
func structPointer_RefBool(p structPointer, f field) *bool {
	return (*bool)(unsafe.Pointer(uintptr(p) + uintptr(f)))
}
251708
func (scope *EvalScope) evalPointerDeref(node *ast.StarExpr) (*Variable, error) {
	xev, err := scope.evalAST(node.X)
	if err != nil {
		return nil, err
	}

	if xev.Kind != reflect.Ptr {
		return nil, fmt.Errorf("expression \"%s\" (%s) can not be dereferenced", exprToString(node.X), xev.TypeString())
	}

	if xev == nilVariable {
		return nil, fmt.Errorf("nil can not be dereferenced")
	}

	if len(xev.Children) == 1 {
		// this branch is here to support pointers constructed with typecasts from ints
		return &(xev.Children[0]), nil
	}
	rv := xev.maybeDereference()
	if rv.Addr == 0 {
		return nil, fmt.Errorf("nil pointer dereference")
	}
	return rv, nil
}
821574
func Indirect(v reflect.Value) reflect.Value {
	for v.Kind() == reflect.Ptr {
		v = reflect.Indirect(v)
	}
	return v
}
260617
func _() {
	var _ Event = (*Absolute)(nil)        // assert *Absolute implements Event
	var _ Event = (*FAbsolute)(nil)       // assert *FAbsolute implements Event
	var _ Event = (*Gauge)(nil)           // assert *Gauge implements Event
	var _ Event = (*FGauge)(nil)          // assert *FGauge implements Event
	var _ Event = (*GaugeDelta)(nil)      // assert *GaugeDelta implements Event
	var _ Event = (*FGaugeDelta)(nil)     // assert *FGaugeDelta implements Event
	var _ Event = (*Increment)(nil)       // assert *Increment implements Event
	var _ Event = (*PrecisionTiming)(nil) // assert *PrecisionTiming implements Event
	var _ Event = (*Timing)(nil)          // assert *Timing implements Event
	var _ Event = (*Total)(nil)           // assert *Total implements Event
}
550363
func (d *Decoder) decodeBasic(name string, data interface{}, val reflect.Value) error {
	if val.IsValid() && val.Elem().IsValid() {
		return d.decode(name, data, val.Elem())
	}

	dataVal := reflect.ValueOf(data)

	// If the input data is a pointer, and the assigned type is the dereference
	// of that exact pointer, then indirect it so that we can assign it.
	// Example: *string to string
	if dataVal.Kind() == reflect.Ptr && dataVal.Type().Elem() == val.Type() {
		dataVal = reflect.Indirect(dataVal)
	}

	if !dataVal.IsValid() {
		dataVal = reflect.Zero(val.Type())
	}

	dataValType := dataVal.Type()
	if !dataValType.AssignableTo(val.Type()) {
		return fmt.Errorf(
			"'%s' expected type '%s', got '%s'",
			name, val.Type(), dataValType)
	}

	val.Set(dataVal)
	return nil
}
1055963
func (d *dumpState) dumpPtr(v reflect.Value) {
	// Remove pointers at or below the current depth from map used to detect
	// circular refs.
	for k, depth := range d.pointers {
		if depth >= d.depth {
			delete(d.pointers, k)
		}
	}

	// Keep list of all dereferenced pointers to show later.
	pointerChain := make([]uintptr, 0)

	// Figure out how many levels of indirection there are by dereferencing
	// pointers and unpacking interfaces down the chain while detecting circular
	// references.
	nilFound := false
	cycleFound := false
	indirects := 0
	ve := v
	for ve.Kind() == reflect.Ptr {
		if ve.IsNil() {
			nilFound = true
			break
		}
		indirects++
		addr := ve.Pointer()
		pointerChain = append(pointerChain, addr)
		if pd, ok := d.pointers[addr]; ok && pd < d.depth {
			cycleFound = true
			indirects--
			break
		}
		d.pointers[addr] = d.depth

		ve = ve.Elem()
		if ve.Kind() == reflect.Interface {
			if ve.IsNil() {
				nilFound = true
				break
			}
			ve = ve.Elem()
		}
	}

	// Display type information.
	d.w.Write(openParenBytes)
	d.w.Write(bytes.Repeat(asteriskBytes, indirects))
	d.w.Write([]byte(ve.Type().String()))
	d.w.Write(closeParenBytes)

	// Display pointer information.
	if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 {
		d.w.Write(openParenBytes)
		for i, addr := range pointerChain {
			if i > 0 {
				d.w.Write(pointerChainBytes)
			}
			printHexPtr(d.w, addr)
		}
		d.w.Write(closeParenBytes)
	}

	// Display dereferenced value.
	d.w.Write(openParenBytes)
	switch {
	case nilFound:
		d.w.Write(nilAngleBytes)

	case cycleFound:
		d.w.Write(circularBytes)

	default:
		d.ignoreNextType = true
		d.dump(ve)
	}
	d.w.Write(closeParenBytes)
}
876410
func toSlice(from []interface{}, ptr interface{}) {
	// Value of the pointer to the target
	obj := reflect.Indirect(reflect.ValueOf(ptr))
	// We can't just convert from interface{} to whatever the target is (diff memory layout),
	// so we need to create a New slice of the proper type and copy the values individually
	t := reflect.TypeOf(ptr).Elem()
	tt := t.Elem()
	slice := reflect.MakeSlice(t, len(from), len(from))
	// Copying the data, val is an addressable Pointer of the actual target type
	val := reflect.Indirect(reflect.New(tt))
	for i := 0; i < len(from); i++ {
		v := reflect.ValueOf(from[i])
		if v.IsValid() && v.Type().ConvertibleTo(tt) {
			val.Set(v.Convert(tt))
		} else {
			val.Set(reflect.Zero(tt))
		}
		slice.Index(i).Set(val)
	}
	// Ok now assign our slice to the target pointer
	obj.Set(slice)
}
672284
func indirect(v reflect.Value) reflect.Value {
	if v.Kind() == reflect.Ptr && v.Elem().Type() != derefbigT {
		return indirect(v.Elem())
	}
	return v
}
1249282
func (inode *Inode) DeRef(n uint64) (stale bool) {
	inode.logFuse("DeRef", n, inode.refcnt)

	if inode.refcnt < n {
		panic(fmt.Sprintf("deref %v from %v", n, inode.refcnt))
	}

	inode.refcnt -= n

	stale = (inode.refcnt == 0)
	return
}
270688
func init() {
	zeroArg = make([]reflect.Value, 0)
	zeroArgInterf = make([]interface{}, 0)
	trueInterf = true
	falseInterf = false
	nilInterf = nil
}