示例#1
0
文件: liteapp.go 项目: b-s-a/liteide
func cdrv_main(args []string) int {
	argc := len(args)
	var cargs []*C.char
	for _, arg := range args {
		ptr := C.CString(arg)
		defer C.free(unsafe.Pointer(ptr)) //释放内存
		cargs = append(cargs, ptr)
	}
	C.cdrv_init_ex()
	return int(C.cdrv_main(C.int(argc), &cargs[0]))
}
示例#2
0
func cdrv_main(args []string) int {
	argc := len(args)
	var cargs []*C.char
	for _, arg := range args {
		size := len(arg)
		data := make([]C.char, size+1)
		for i := 0; i < size; i++ {
			data[i] = (C.char)(arg[i])
		}
		data[size] = 0
		cargs = append(cargs, &data[0])
	}
	C.cdrv_init_ex()
	return int(C.cdrv_main(C.int(argc), &cargs[0]))
}