當前位置: 首頁>>代碼示例>>Golang>>正文


Golang C.virTypedParamsFree函數代碼示例

本文整理匯總了Golang中C.virTypedParamsFree函數的典型用法代碼示例。如果您正苦於以下問題:Golang virTypedParamsFree函數的具體用法?Golang virTypedParamsFree怎麽用?Golang virTypedParamsFree使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了virTypedParamsFree函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: BlockStatsFlags

func (d *VirDomain) BlockStatsFlags(disk string, params *VirTypedParameters, nParams int, flags uint32) (int, error) {
	var cParams C.virTypedParameterPtr
	cDisk := C.CString(disk)
	defer C.free(unsafe.Pointer(cDisk))

	cParamsLen := C.int(nParams)

	if params != nil && nParams > 0 {
		cParams = (C.virTypedParameterPtr)(C.calloc(C.size_t(nParams), C.size_t(unsafe.Sizeof(C.struct__virTypedParameter{}))))
		defer C.virTypedParamsFree(cParams, cParamsLen)
	} else {
		cParams = nil
	}

	result := int(C.virDomainBlockStatsFlags(d.ptr, cDisk, (C.virTypedParameterPtr)(cParams), &cParamsLen, C.uint(flags)))
	if result == -1 {
		return result, GetLastError()
	}

	if cParamsLen > 0 && params != nil {
		params.loadFromCPtr(cParams, nParams)
	}

	return int(cParamsLen), nil
}
開發者ID:rgbkrk,項目名稱:libvirt-go,代碼行數:25,代碼來源:domain.go

示例2: GetCPUStats

func (d *VirDomain) GetCPUStats(params *VirTypedParameters, nParams int, startCpu int, nCpus uint32, flags uint32) (int, error) {
	var cParams C.virTypedParameterPtr
	var cParamsLen int

	cParamsLen = int(nCpus) * nParams

	if params != nil && cParamsLen > 0 {
		cParams = (C.virTypedParameterPtr)(C.calloc(C.size_t(cParamsLen), C.size_t(unsafe.Sizeof(C.struct__virTypedParameter{}))))
		defer C.virTypedParamsFree(cParams, C.int(cParamsLen))
	} else {
		cParamsLen = 0
		cParams = nil
	}

	result := int(C.virDomainGetCPUStats(d.ptr, (C.virTypedParameterPtr)(cParams), C.uint(nParams), C.int(startCpu), C.uint(nCpus), C.uint(flags)))
	if result == -1 {
		return result, GetLastError()
	}

	if cParamsLen > 0 {
		params.loadFromCPtr(cParams, cParamsLen)
	}

	return result, nil
}
開發者ID:rgbkrk,項目名稱:libvirt-go,代碼行數:25,代碼來源:domain.go

示例3: BlockCopy

func (d *VirDomain) BlockCopy(disk string, destXML string, params VirTypedParameters, flags uint32) error {

	cDisk := C.CString(disk)
	defer C.free(unsafe.Pointer(cDisk))
	cDestXML := C.CString(destXML)
	defer C.free(unsafe.Pointer(cDestXML))
	if cParams, cnParams, err := params.loadToCPtr(); err != nil {
		C.virTypedParamsFree(cParams, cnParams)
		return err
	} else {
		defer C.virTypedParamsFree(cParams, cnParams)

		result := int(C.virDomainBlockCopy(d.ptr, cDisk, cDestXML, cParams, cnParams, C.uint(flags)))
		if result == -1 {
			return GetLastError()
		}
	}
	return nil
}
開發者ID:rgbkrk,項目名稱:libvirt-go,代碼行數:19,代碼來源:domain_1.2.14.go

示例4: NewTypedParameters

func NewTypedParameters(nparams int) *TypedParameters {
	t := new(TypedParameters)
	if nparams > 0 {
		t.cptr = C.virTypedParameterAllocate(C.int(nparams))
		t.capacity = C.int(nparams)
	}
	runtime.SetFinalizer(t, func(t *TypedParameters) {
		if t.cptr != nil {
			C.virTypedParamsFree(t.cptr, t.length)
		}
	})
	return t
}
開發者ID:hooklift,項目名稱:golibvirt,代碼行數:13,代碼來源:typed_parameter.go

示例5: GetInterfaceParameters

// Warning: No test written for this function
func (d *VirDomain) GetInterfaceParameters(device string, params *VirTypedParameters, nParams *int, flags uint32) (int, error) {
	var cParams C.virTypedParameterPtr

	if params != nil && *nParams > 0 {
		cParams = (C.virTypedParameterPtr)(C.calloc(C.size_t(*nParams), C.size_t(unsafe.Sizeof(C.struct__virTypedParameter{}))))
		defer C.virTypedParamsFree(cParams, C.int(*nParams))
	} else {
		cParams = nil
	}

	result := int(C.virDomainGetInterfaceParameters(d.ptr, C.CString(device), (C.virTypedParameterPtr)(cParams), (*C.int)(unsafe.Pointer(nParams)), C.uint(flags)))
	if result == -1 {
		return result, GetLastError()
	}

	if params != nil && *nParams > 0 {
		params.loadFromCPtr(cParams, *nParams)
	}

	return result, nil
}
開發者ID:juito,項目名稱:hyper,代碼行數:22,代碼來源:domain.go


注:本文中的C.virTypedParamsFree函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。