// Deallocate the resource.
424512
func (r *AutoVLANCfgResource) Deallocate(value interface{}) error {
	oper := &AutoVLANOperResource{}
	oper.StateDriver = r.StateDriver
	err := oper.Read(r.ID)
	if err != nil {
		return err
	}

	vlan, ok := value.(uint)
	if !ok {
		return core.Errorf("Invalid type for vlan value")
	}
	if oper.FreeVLANs.Test(vlan) {
		return nil
	}
	oper.FreeVLANs.Set(vlan)

	return oper.Write()
}
256745
func (c *Conn) Deallocate(name string) error {
	return c.deallocateContext(context.Background(), name)
}
636760
func (r *resourceAllocator) DetachNetwork(ctx context.Context, aID string) error {
	return r.agent.withSession(ctx, func(session *session) error {
		client := api.NewResourceAllocatorClient(session.conn.ClientConn)
		_, err := client.DetachNetwork(ctx, &api.DetachNetworkRequest{
			AttachmentID: aID,
		})

		return err
	})
}
93427
func (ptree *ptree) Dispose() {
	if atomic.LoadUint64(&ptree.disposed) == 1 {
		return
	}
	ptree.actions.Dispose()
	atomic.StoreUint64(&ptree.disposed, 1)
	close(ptree.disposeChannel)
}
1043756
func (p *allocator) Release(item string) {

	// Do not release when the channel is full. These can happen when we resync
	// stopped containers.
	if len(p.allocate) == cap(p.allocate) {
		return
	}

	intItem, err := strconv.Atoi(item)
	if err != nil {
		return
	}
	p.allocate <- intItem
}
703518
func (o *OracleEnviron) Destroy(ctx context.ProviderCallContext) error {
	return common.Destroy(o, ctx)
}
137558
func (deallocator *Deallocator) processService(ctx context.Context, service *api.Service) (bool, error) {
	if !service.PendingDelete {
		return false, nil
	}

	var (
		tasks []*api.Task
		err   error
	)

	deallocator.store.View(func(tx store.ReadTx) {
		tasks, err = store.FindTasks(tx, store.ByServiceID(service.ID))
	})

	if err != nil {
		log.G(ctx).WithError(err).Errorf("failed to retrieve the list of tasks for service %v", service.ID)
		// if in doubt, let's proceed to clean up the service anyway
		// better to clean up resources that shouldn't be cleaned up yet
		// than ending up with a service and some resources lost in limbo forever
		return true, deallocator.deallocateService(ctx, service)
	} else if len(tasks) == 0 {
		// no tasks remaining for this service, we can clean it up
		return true, deallocator.deallocateService(ctx, service)
	}
	deallocator.services[service.ID] = &serviceWithTaskCounts{service: service, taskCount: len(tasks)}
	return false, nil
}
309208
func (dr *dockerMetadataStorage) Remove(resourceID string) error {
	ops := []txn.Op{{
		C:      dockerResourcesC,
		Id:     resourceID,
		Remove: true,
	}}
	err := dr.st.db().RunTransaction(ops)
	return errors.Annotate(err, "failed to remove Docker resource")
}
42472
func (a *adapter) Destroy(app string) error {
	// Check first if the map of file pointers even contains the file pointer we want so we can avoid
	// waiting for / obtaining a lock unnecessarily
	f, ok := a.files[app]
	if ok {
		// Ensure no other goroutine is trying to modify the file pointer map while we're trying to
		// clean up
		a.mutex.Lock()
		defer a.mutex.Unlock()
		exists, err := fileExists(f.Name())
		if err != nil {
			return err
		}
		if exists {
			if err := os.Remove(f.Name()); err != nil {
				return err
			}
		}
		delete(a.files, app)
	}
	return nil
}
1252068
func (r Resource) Delete(request *restful.Request, response *restful.Response) {
	if resource, ok := r.Parent.(DeleteSupported); ok {
		context := r.Context.NewAPIContext()
		if resource.DeleteAuthRequired() {
			auth, err := context.Authentication(request)
			if err != nil || auth == nil {
				ErrorResponseHandler(request, response, err, NewErrorResponse(
					http.StatusUnauthorized,
					"Invalid accesstoken",
					"DELETE"))
				return
			}
		}

		resource.Delete(context, request, response)
		request.SetAttribute("context", context)
	}
}
1125928
func (fs *memFS) deallocateInode(id fuseops.InodeID) {
	fs.freeInodes = append(fs.freeInodes, id)
	fs.inodes[id] = nil
}
1107792
func Close(ctx context.Context, c io.Closer) {
	// need to verify that the value of the `c` interface if not nil, too
	if c != nil && !reflect.ValueOf(c).IsNil() {
		err := c.Close()
		if err != nil {
			log.Error(ctx, map[string]interface{}{"error": err.Error()}, "error while closing the resource")
		}
	}

}
1257878
func (s *Server) DeleteResource(ctx context.Context, q *ApplicationResourceDeleteRequest) (*ApplicationResponse, error) {
	resourceRequest := &ApplicationResourceRequest{
		Name:         q.Name,
		Namespace:    q.Namespace,
		ResourceName: q.ResourceName,
		Kind:         q.Kind,
		Version:      q.Version,
		Group:        q.Group,
	}
	res, config, a, err := s.getAppResource(ctx, rbacpolicy.ActionDelete, resourceRequest)
	if err != nil {
		return nil, err
	}

	if err := s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceApplications, rbacpolicy.ActionDelete, appRBACName(*a)); err != nil {
		return nil, err
	}
	var force bool
	if q.Force != nil {
		force = *q.Force
	}
	err = s.kubectl.DeleteResource(config, res.GroupKindVersion(), res.Name, res.Namespace, force)
	if err != nil {
		return nil, err
	}
	s.logEvent(a, ctx, argo.EventReasonResourceDeleted, fmt.Sprintf("deleted resource %s/%s '%s'", q.Group, q.Kind, q.ResourceName))
	return &ApplicationResponse{}, nil
}
1197212
func (opts *IngestExternalFileOptions) Destroy() {
	C.rocksdb_ingestexternalfileoptions_destroy(opts.c)
	opts.c = nil
}
624125
func (opts *UniversalCompactionOptions) Destroy() {
	C.rocksdb_universal_compaction_options_destroy(opts.c)
	opts.c = nil
}
655498
func (op *PortAllocationOperation) Allocate(port int) error {
	if op.dryRun {
		if op.pa.Has(port) {
			return ErrAllocated
		}
		for _, a := range op.allocated {
			if port == a {
				return ErrAllocated
			}
		}
		op.allocated = append(op.allocated, port)
		return nil
	}

	err := op.pa.Allocate(port)
	if err == nil {
		op.allocated = append(op.allocated, port)
	}
	return err
}
917386
func (s *scene) Dispose(key string) (interface{}, error) {
	command := &envelope{
		kind: disposeProp,
		box: &box{
			key: key,
		},
		respChan: make(chan *envelope, 1),
	}
	resp, err := s.command(command)
	if err != nil {
		return nil, err
	}
	return resp.box.prop, nil
}