示例#1
0
// LoadDict wraps enchant_broker_request_dict, and adds
// the loaded dictionary to the Enchant instance.
// It takes a language code name, such as "en_GB", as string
// argument, and it returns a EnchantDict representation
// of this dictionary.
func (e *Enchant) LoadDict(name string) {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))

	if e.dict != nil {
		C.enchant_broker_free_dict(e.broker, e.dict)
	}
	dict := C.enchant_broker_request_dict(e.broker, cName)
	e.dict = dict
}
示例#2
0
// Free frees the Enchant broker and dictionary, and needs
// to be called when use of the library is no longer needed
// to prevent memory leaks.
func (e *Enchant) Free() {
	if e.dict != nil {
		C.enchant_broker_free_dict(e.broker, e.dict)
	}
	C.enchant_broker_free(e.broker)
}
示例#3
0
文件: enchant.go 项目: taruti/enchant
// FreeDict frees a dictionary.
func (e *Enchant) FreeDict(d *Dict) {
	C.enchant_broker_free_dict(e.broker, d.dict)
}