Exemplo n.º 1
0
func (dict *Dictionary) set(key, value string, flags C.int) error {
	cKey := C.CString(key)
	defer C.free(unsafe.Pointer(cKey))
	cValue := C.CString(value)
	defer C.free(unsafe.Pointer(cValue))
	code := ErrorCode(C.av_dict_set(&dict.CAVDictionary, cKey, cValue, flags))
	if code < 0 {
		return NewErrorFromCode(code)
	}
	return nil
}
Exemplo n.º 2
0
Arquivo: dict.go Projeto: jasonmoo/gmf
func NewDict(pairs []Pair) *Dict {
	this := &Dict{avDict: nil}

	for _, pair := range pairs {
		ckey := C.CString(pair.Key)
		cval := C.CString(pair.Val)

		if ret := C.av_dict_set(&this.avDict, ckey, cval, 0); int(ret) < 0 {
			log.Printf("unable to set key '%s' value '%d', error: %s\n", pair.Key, pair.Val, AvError(int(ret)))
		}

		// C.free(unsafe.Pointer(ckey))
		// C.free(unsafe.Pointer(cval))
	}

	return this
}