// makeErrorSlice is a handy function to make a slice of errors or nil errors
487835
func makeErrorSlice(len int, e error) []error {
	errors := make([]error, len)
	for inx := 0; inx < len; inx = inx + 1 {
		errors[inx] = e
	}
	return errors
}
368541
func copySlice(slice []byte) []byte {
	ret := make([]byte, len(slice))
	copy(ret, slice)
	return ret
}
1157622
func (lib *Lib) MakeError(major, minor C.OM_uint32) *Error {
	return &Error{
		Lib:   lib,
		Major: MajorStatus(major),
		Minor: minor,
	}
}
1242439
func (err Error) Error() string {
	switch children := err.Nested.(type) {
	case nil:
		return err.Message

	case []NestedError:
		return formatNestedError(err, children)

	default:
		return err.Message + "\n" +
			BranchDelimiter +
			strings.Replace(
				String(err.Nested),
				"\n",
				"\n"+strings.Repeat(" ", BranchIndent),
				-1,
			)
	}
}
430318
func ReadStringSlice(r Reader, sl *[]string) (err error) {
	var l VInt
	if err := l.ReadFrom(r, -1); err != nil {
		return errorsp.WithStacks(err)
	}
	if cap(*sl) < int(l) {
		*sl = make([]string, l)
	} else {
		*sl = (*sl)[:l]
	}
	for i := range *sl {
		if err := (*String)(&(*sl)[i]).ReadFrom(r, -1); err != nil {
			return errorsp.WithStacks(err)
		}
	}
	return nil
}
383514
func addressableSlice(slice interface{}) reflect.Value {
	v := reflect.ValueOf(slice)
	p := reflect.New(v.Type())
	p.Elem().Set(v)
	return p.Elem()
}
822725
func ExitError(ctx context.Context, exitCode int, err error, format string, args ...interface{}) error {
	if err != nil {
		out.Debug(ctx, "Stacktrace: %+v", err)
	}
	return cli.NewExitError(fmt.Sprintf(format, args...), exitCode)
}
412935
func (set IdentifierSet) ToSlice() []Identifier {
	var s []Identifier
	for v := range set {
		s = append(s, v)
	}
	return s
}
528995
func ptrUcs2Slice(ptr *uint16, lenUcs2 int) []uint16 {
	return *(*[]uint16)(unsafe.Pointer(&reflect.SliceHeader{
		Data: uintptr(unsafe.Pointer(ptr)),
		Len:  lenUcs2,
		Cap:  lenUcs2}))
}
497097
func wrapError(status uint16, err error) error {
	return &Error{status, err.Error(), err}
}
537506
func makeCLIError(msg string, args ...interface{}) error {
	return commandLineError{fmt.Errorf(msg, args...)}
}
1007843
func MakeErrorHandler(hfcn http.HandlerFunc) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		// catch errors
		defer func() {
			if err, ok := recover().(error); ok {
				w.WriteHeader(http.StatusInternalServerError)
				fmt.Fprintf(w, "INTERNAL ERROR (dmp): 500 HTTP error:\n%v", err)
			}
		}()
		// call the wrapped handler
		hfcn(w, r)
	}
}
935989
func IntSlice(s Interface) []int {
	slice := make([]int, 0)
	for _, item := range s.List() {
		v, ok := item.(int)
		if !ok {
			continue
		}

		slice = append(slice, v)
	}
	return slice
}
448388
func MakeStaticError(msg string, lr ast.LocationRange) StaticError {
	return StaticError{Msg: msg, Loc: lr}
}
118732
func WrapErrors(errs ...error) error {
	s := []string{}
	for _, e := range errs {
		if e != nil {
			s = append(s, e.Error())
		}
	}
	return errors.New(strings.Join(s, ": "))
}
1269728
func charSlice(data **C.char, len C.int) []*C.char {
	var value []*C.char
	sH := (*reflect.SliceHeader)(unsafe.Pointer(&value))
	sH.Cap, sH.Len, sH.Data = int(len), int(len), uintptr(unsafe.Pointer(data))
	return value
}
1005084
func (s CPUSet) ToSlice() []int {
	result := []int{}
	for cpu := range s.elems {
		result = append(result, cpu)
	}
	sort.Ints(result)
	return result
}