// Copy the state of the virtual machine environment
356565
func (e *Env) Copy() *Env {
	e.Lock()
	defer e.Unlock()
	copy := Env{
		name:     e.name,
		env:      make(map[string]reflect.Value),
		typ:      make(map[string]reflect.Type),
		parent:   e.parent,
		external: e.external,
	}
	for name, value := range e.env {
		copy.env[name] = value
	}
	for name, typ := range e.typ {
		copy.typ[name] = typ
	}
	return &copy
}
1291134
func (h *Host) Copy(c *Host) {
	h.Hostname = c.Hostname
	h.IPv4Addr = copyIP(c.IPv4Addr)
	h.IPv4Mask = copyIPMask(c.IPv4Mask)
	h.IPv6Addr = copyIP(c.IPv6Addr)
	h.IPv6Mask = copyIPMask(c.IPv6Mask)
}
141620
func (*ExecRunner) Copy(f assets.CopyableFile) error {
	if err := os.MkdirAll(f.GetTargetDir(), os.ModePerm); err != nil {
		return errors.Wrapf(err, "error making dirs for %s", f.GetTargetDir())
	}
	targetPath := filepath.Join(f.GetTargetDir(), f.GetTargetName())
	if _, err := os.Stat(targetPath); err == nil {
		if err := os.Remove(targetPath); err != nil {
			return errors.Wrapf(err, "error removing file %s", targetPath)
		}

	}
	target, err := os.Create(targetPath)
	if err != nil {
		return errors.Wrapf(err, "error creating file at %s", targetPath)
	}
	perms, err := strconv.ParseInt(f.GetPermissions(), 8, 0)
	if err != nil {
		return errors.Wrapf(err, "error converting permissions %s to integer", f.GetPermissions())
	}
	if err := os.Chmod(targetPath, os.FileMode(perms)); err != nil {
		return errors.Wrapf(err, "error changing file permissions for %s", targetPath)
	}

	if _, err = io.Copy(target, f); err != nil {
		return errors.Wrapf(err, `error copying file %s to target location:
do you have the correct permissions?`,
			targetPath)
	}
	return target.Close()
}
928801
func copyEnvVarSlice(in []corev1.EnvVar) []corev1.EnvVar {
	out := make([]corev1.EnvVar, len(in))
	copy(out, in)
	return out
}
1197237
func (entry *Entry) Copy() (*Entry, error) {
	var cdst C.acl_entry_t
	rv, _ := C.acl_copy_entry(cdst, entry.e)
	if rv < 0 {
		return nil, fmt.Errorf("unable to copy entry")
	}
	return &Entry{cdst}, nil
}
802118
func (m *Manager) Copy() *Manager {
	sess := m.db.Session.Copy()
	copy := New(m.db.With(sess), m.Cfg)
	// TODO (m0sth8): implement copy through the interface
	m.Permission.Copy(copy.Permission)
	m.Vulndb.Copy(copy.Vulndb)
	return copy
}
724887
func (dbcfgs *DBConfigs) Copy() *DBConfigs {
	result := &DBConfigs{userConfigs: make(map[string]*userConfig)}
	for k, u := range dbcfgs.userConfigs {
		newu := *u
		result.userConfigs[k] = &newu
	}
	result.DBName.Set(dbcfgs.DBName.Get())
	result.SidecarDBName.Set(dbcfgs.SidecarDBName.Get())
	return result
}
84042
func (cfg *EndpointIPAMConfig) Copy() *EndpointIPAMConfig {
	cfgCopy := *cfg
	cfgCopy.LinkLocalIPs = make([]string, 0, len(cfg.LinkLocalIPs))
	cfgCopy.LinkLocalIPs = append(cfgCopy.LinkLocalIPs, cfg.LinkLocalIPs...)
	return &cfgCopy
}
1045627
func (c *Calcium) Copy(ctx context.Context, opts *types.CopyOptions) (chan *types.CopyMessage, error) {
	ch := make(chan *types.CopyMessage)
	go func() {
		defer close(ch)
		wg := sync.WaitGroup{}
		log.Infof("[Copy] Copy %d containers files", len(opts.Targets))
		// container one by one
		for cid, paths := range opts.Targets {
			wg.Add(1)
			go func(cid string, paths []string) {
				defer wg.Done()
				container, err := c.GetContainer(ctx, cid)
				if err != nil {
					log.Errorf("[Copy] Error when get container %s, err %v", cid, err)
					ch <- makeCopyMessage(cid, cluster.CopyFailed, "", "", err, nil)
					return
				}
				for _, path := range paths {
					wg.Add(1)
					go func(path string) {
						defer wg.Done()
						resp, name, err := container.Engine.VirtualizationCopyFrom(ctx, container.ID, path)
						if err != nil {
							log.Errorf("[Copy] Error during CopyFromContainer: %v", err)
							ch <- makeCopyMessage(cid, cluster.CopyFailed, "", path, err, nil)
							return
						}
						ch <- makeCopyMessage(cid, cluster.CopyOK, name, path, nil, resp)
					}(path)
				}
			}(cid, paths)
		}
		wg.Wait()
	}()
	return ch, nil
}
504381
func (r *ResourceLifecycle) Copy() *ResourceLifecycle {
	n := &ResourceLifecycle{
		CreateBeforeDestroy: r.CreateBeforeDestroy,
		PreventDestroy:      r.PreventDestroy,
		IgnoreChanges:       make([]string, len(r.IgnoreChanges)),
	}
	copy(n.IgnoreChanges, r.IgnoreChanges)
	return n
}
1026956
func (d *AllocDir) Copy() *AllocDir {
	d.mu.RLock()
	defer d.mu.RUnlock()

	if d == nil {
		return nil
	}
	dcopy := &AllocDir{
		AllocDir:  d.AllocDir,
		SharedDir: d.SharedDir,
		TaskDirs:  make(map[string]*TaskDir, len(d.TaskDirs)),
		logger:    d.logger,
	}
	for k, v := range d.TaskDirs {
		dcopy.TaskDirs[k] = v.Copy()
	}
	return dcopy
}
33769
func (e *Engine) VirtualizationCopyTo(ctx context.Context, ID, path string, content io.Reader, AllowOverwriteDirWithFile, CopyUIDGID bool) error {
	return e.client.CopyToContainer(ctx, ID, path, content, dockertypes.CopyToContainerOptions{AllowOverwriteDirWithFile: AllowOverwriteDirWithFile, CopyUIDGID: CopyUIDGID})
}
1086659
func (c *Config) Copy(cfgs ...*Config) *Config {
	dst := &Config{}
	dst.MergeIn(c)

	for _, cfg := range cfgs {
		dst.MergeIn(cfg)
	}

	return dst
}
183820
func (h *HookState) Copy() *HookState {
	if h == nil {
		return nil
	}

	c := new(HookState)
	*c = *h
	c.Data = helper.CopyMapStringString(h.Data)
	c.Env = helper.CopyMapStringString(h.Env)
	return c
}
993997
func (a *Automaton) copy(other *Automaton) {
	// bulk copy and then fixup the state pointers
	stateOffset := a.numStates()
	a.states = append(a.states, other.states...)
	for i := 0; i < len(other.states); i += 2 {
		if a.states[stateOffset*2+i] != -1 {
			a.states[stateOffset*2+i] += len(a.transitions)
		}
	}
	otherAcceptState := other.isAccept
	for state := otherAcceptState.NextSetBit(0); state != -1; state = otherAcceptState.NextSetBit(state + 1) {
		a.setAccept(stateOffset+int(state), true)
	}

	// bulk copy and then fixup dest for each transition
	transOffset := len(a.transitions)
	a.transitions = append(a.transitions, other.transitions...)
	for i := 0; i < len(other.transitions); i += 3 {
		a.transitions[transOffset+i] += stateOffset
	}

	if !other.deterministic {
		a.deterministic = false
	}
}
901485
func (cp *ChanPrivs) Copy() *ChanPrivs {
	if cp == nil {
		return nil
	}
	c := *cp
	return &c
}
87570
func (e *Env) DeepCopy() *Env {
	copy := e.Copy()
	if copy.parent != nil {
		copy.parent = copy.parent.DeepCopy()
	}
	return copy
}