// RemovePtrFromType will return the type of t and strips away any pointer(s)
// in front of the actual type.
773065
func RemovePtrFromType(t interface{}) reflect.Type {
	var v reflect.Type
	if rt, isType := t.(reflect.Type); isType {
		v = rt
	} else {
		v = reflect.TypeOf(t)
	}
	for v.Kind() == reflect.Ptr {
		v = v.Elem()
	}
	return v
}
731103
func isOutputPtrOfPrim(fnName string, p bg.Parameter) bool {
	if !isOutput(fnName, p) && !isIO(fnName, p) {
		return false
	}
	if !p.IsPointer() {
		return false
	}
	return isBuiltin(depointerize(nameOfType(p.Type())))
}
1004373
func FindByType(g Graph, listPtr interface{}) []reflect.Value {
	ptrType := reflect.TypeOf(listPtr)
	if ptrType.Kind() != reflect.Ptr {
		panic(fmt.Sprintf("listPtr (%v) is not a pointer", ptrType))
	}

	listType := ptrType.Elem()
	if listType.Kind() != reflect.Slice {
		panic(fmt.Sprintf("listPtr (%v) is not a pointer to a slice or array", ptrType))
	}

	listValue := reflect.ValueOf(listPtr).Elem()

	values := g.ResolveByType(listType.Elem())
	listValue = reflect.Append(listValue, values...)

	// update the listPtr value
	reflect.ValueOf(listPtr).Elem().Set(listValue)

	return values
}
6546
func int64ptr(i interface{}) *int64 {
	v := reflect.ValueOf(i)
	if !v.Type().ConvertibleTo(rTypeInt64) {
		return nil
	}
	j := v.Convert(rTypeInt64).Interface().(int64)
	return &j
}
811862
func RemoveAllRelative(path string, root *os.File) error {
	fi, err := LstatRelative(path, root)
	if err != nil {
		if os.IsNotExist(err) {
			return nil
		}
		return err
	}
	fileAttributes := fi.Sys().(*syscall.Win32FileAttributeData).FileAttributes
	if fileAttributes&syscall.FILE_ATTRIBUTE_DIRECTORY == 0 || fileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT != 0 {
		// If this is a reparse point, it can't have children. Simple remove will do.
		err := RemoveRelative(path, root)
		if err == nil || os.IsNotExist(err) {
			return nil
		}
		return err
	}

	// It is necessary to use os.Open as Readdirnames does not work with
	// OpenRelative. This is safe because the above lstatrelative fails
	// if the target is outside the root, and we know this is not a
	// symlink from the above FILE_ATTRIBUTE_REPARSE_POINT check.
	fd, err := os.Open(filepath.Join(root.Name(), path))
	if err != nil {
		if os.IsNotExist(err) {
			// Race. It was deleted between the Lstat and Open.
			// Return nil per RemoveAll's docs.
			return nil
		}
		return err
	}

	// Remove contents & return first error.
	for {
		names, err1 := fd.Readdirnames(100)
		for _, name := range names {
			err1 := RemoveAllRelative(path+string(os.PathSeparator)+name, root)
			if err == nil {
				err = err1
			}
		}
		if err1 == io.EOF {
			break
		}
		// If Readdirnames returned an error, use it.
		if err == nil {
			err = err1
		}
		if len(names) == 0 {
			break
		}
	}
	fd.Close()

	// Remove directory.
	err1 := RemoveRelative(path, root)
	if err1 == nil || os.IsNotExist(err1) {
		return nil
	}
	if err == nil {
		err = err1
	}
	return err
}
1016743
func RemoveEndsFilter(x Sexp) bool {
	switch n := x.(type) {
	case *SexpSentinel:
		if n.Val == SexpEnd.Val {
			return false
		}
	}
	return true
}
774427
func (a *API) removeShapeRef(ref *ShapeRef) {
	if ref.Shape == nil {
		return
	}

	ref.Shape.removeRef(ref)
	if len(ref.Shape.refs) == 0 {
		a.removeShape(ref.Shape)
	}
}
319146
func RemoveCRDCondition(crd *CustomResourceDefinition, conditionType CustomResourceDefinitionConditionType) {
	newConditions := []CustomResourceDefinitionCondition{}
	for _, condition := range crd.Status.Conditions {
		if condition.Type != conditionType {
			newConditions = append(newConditions, condition)
		}
	}
	crd.Status.Conditions = newConditions
}
229458
func removexattr(path string, attr string, options int) (err error) {
	var _p0 *byte
	_p0, err = syscall.BytePtrFromString(path)
	if err != nil {
		return
	}
	var _p1 *byte
	_p1, err = syscall.BytePtrFromString(attr)
	if err != nil {
		return
	}
	_, _, e1 := syscall.Syscall(syscall.SYS_REMOVEXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(options))
	if e1 != 0 {
		err = e1
	}
	return
}
48150
func (kcp *KCP) remove_front(q []segment, n int) []segment {
	if n > len(q)/2 {
		newn := copy(q, q[n:])
		return q[:newn]
	}
	return q[n:]
}
99284
func toType(p interface{}) reflect.Type {
	t := reflect.ValueOf(p).Type()
	if t.Kind() == reflect.Ptr {
		t = t.Elem()
	}
	return t
}
140283
func (c *Client) RemoveFromLoadBalancerRule(p *RemoveFromLoadBalancerRuleParameter) (*Result, error) {
	obj, err := c.Request("removeFromLoadBalancerRule", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Result), err
}
1060419
func Remove(obj interface{}, pointer string) (rv interface{}, err error) {
	defer func() {
		if e := recover(); e != nil {
			err = fmt.Errorf("invalid JSON pointer: %q: %v", pointer, e)
		}
	}()
	tokens, err := parse(pointer)
	if err != nil {
		return nil, err
	}

	i := 0
	v := reflect.ValueOf(obj)
	var p, pp reflect.Value
	var token, ptoken string
	if len(tokens) > 0 && tokens[0] != "" {
		for i < len(tokens) {
			for v.Kind() == reflect.Interface {
				v = v.Elem()
			}
			pp = p
			p = v
			ptoken = token
			token = tokens[i]
			if n, err := strconv.Atoi(token); err == nil && isIndexed(v) {
				v = v.Index(n)
			} else {
				v = v.MapIndex(reflect.ValueOf(token))
			}
			i++
		}
	} else {
		return nil, fmt.Errorf("pointer should have element")
	}

	var nv reflect.Value
	if p.Kind() == reflect.Map {
		nv = reflect.MakeMap(p.Type())
		for _, mk := range p.MapKeys() {
			if mk.String() != token {
				nv.SetMapIndex(mk, p.MapIndex(mk))
			}
		}
	} else {
		nv = reflect.Zero(p.Type())
		n, _ := strconv.Atoi(token)
		for m := 0; m < p.Len(); m++ {
			if n != m {
				nv = reflect.Append(nv, p.Index(m))
			}
		}
	}

	if !pp.IsValid() {
		obj = nv.Interface()
	} else if pp.Kind() == reflect.Map {
		pp.SetMapIndex(reflect.ValueOf(ptoken), nv)
	} else {
		p.Set(reflect.ValueOf(nv))
	}
	return obj, nil
}
894226
func makePtrDecoder(typ reflect.Type) (decoder, error) {
	etype := typ.Elem()
	etypeinfo, err := cachedTypeInfo1(etype, tags{})
	if err != nil {
		return nil, err
	}
	dec := func(s *Stream, val reflect.Value) (err error) {
		newval := val
		if val.IsNil() {
			newval = reflect.New(etype)
		}
		if err = etypeinfo.decoder(s, newval.Elem()); err == nil {
			val.Set(newval)
		}
		return err
	}
	return dec, nil
}
508981
func readPLPType(ti *typeInfo, r *tdsBuffer) interface{} {
	size := r.uint64()
	var buf *bytes.Buffer
	switch size {
	case _PLP_NULL:
		// null
		return nil
	case _UNKNOWN_PLP_LEN:
		// size unknown
		buf = bytes.NewBuffer(make([]byte, 0, 1000))
	default:
		buf = bytes.NewBuffer(make([]byte, 0, size))
	}
	for true {
		chunksize := r.uint32()
		if chunksize == 0 {
			break
		}
		if _, err := io.CopyN(buf, r, int64(chunksize)); err != nil {
			badStreamPanicf("Reading PLP type failed: %s", err.Error())
		}
	}
	switch ti.TypeId {
	case typeXml:
		return decodeXml(*ti, buf.Bytes())
	case typeBigVarChar, typeBigChar, typeText:
		return decodeChar(ti.Collation, buf.Bytes())
	case typeBigVarBin, typeBigBinary, typeImage:
		return buf.Bytes()
	case typeNVarChar, typeNChar, typeNText:
		return decodeNChar(buf.Bytes())
	case typeUdt:
		return decodeUdt(*ti, buf.Bytes())
	}
	panic("shoulnd't get here")
}
43076
func (d *deployerImpl) removeFromSiteRoot(ctx context.Context, subdir string, files []pkg.FileInfo, keep *pathTree) {
	dirsToCleanup := stringset.New(0)

	for _, f := range files {
		rootRel := filepath.Join(subdir, filepath.FromSlash(f.Name))
		if keep.has(rootRel) {
			continue
		}
		absPath, err := d.fs.RootRelToAbs(rootRel)
		if err != nil {
			logging.Warningf(ctx, "Refusing to remove %q: %s", f.Name, err)
			continue
		}
		if err := d.fs.EnsureFileGone(ctx, absPath); err != nil {
			logging.Warningf(ctx, "Failed to remove a file from the site root: %s", err)
		} else {
			dirsToCleanup.Add(filepath.Dir(absPath))
		}
	}

	if dirsToCleanup.Len() != 0 {
		subdirAbs, err := d.fs.RootRelToAbs(subdir)
		if err != nil {
			logging.Warningf(ctx, "Can't resolve relative %q to absolute path: %s", subdir, err)
		} else {
			removeEmptyTrees(ctx, subdirAbs, dirsToCleanup)
		}
	}
}
297639
func removeNilLRPs(lrps []*models.ActualLRP) []*models.ActualLRP {
	newLRPs := []*models.ActualLRP{}
	for _, l := range lrps {
		if l == nil {
			continue
		}
		newLRPs = append(newLRPs, l)
	}
	return newLRPs
}