mirror of
https://github.com/mappu/miqt.git
synced 2025-01-18 12:50:41 +00:00
genbindings/qstringlist: need a larger malloc for qstring now
This commit is contained in:
parent
b0344564cd
commit
9e7349d4e3
@ -291,8 +291,17 @@ func (gfs *goFileState) emitParameterGo2CABIForwarding(p CppParameter) (preamble
|
|||||||
gfs.imports["runtime"] = struct{}{}
|
gfs.imports["runtime"] = struct{}{}
|
||||||
gfs.imports["unsafe"] = struct{}{}
|
gfs.imports["unsafe"] = struct{}{}
|
||||||
|
|
||||||
|
var mallocSize string
|
||||||
|
if listType.ParameterType == "QString" || listType.ParameterType == "QByteArray" {
|
||||||
|
preamble += "// For the C ABI, malloc a C array of structs\n"
|
||||||
|
mallocSize = "int(unsafe.Sizeof(C.struct_miqt_string{}))"
|
||||||
|
|
||||||
|
} else {
|
||||||
preamble += "// For the C ABI, malloc a C array of raw pointers\n"
|
preamble += "// For the C ABI, malloc a C array of raw pointers\n"
|
||||||
preamble += nameprefix + "_CArray := (*[0xffff]" + listType.parameterTypeCgo() + ")(C.malloc(C.size_t(8 * len(" + p.ParameterName + "))))\n"
|
mallocSize = "8"
|
||||||
|
}
|
||||||
|
|
||||||
|
preamble += nameprefix + "_CArray := (*[0xffff]" + listType.parameterTypeCgo() + ")(C.malloc(C.size_t(" + mallocSize + " * len(" + p.ParameterName + "))))\n"
|
||||||
preamble += "defer C.free(unsafe.Pointer(" + nameprefix + "_CArray))\n"
|
preamble += "defer C.free(unsafe.Pointer(" + nameprefix + "_CArray))\n"
|
||||||
|
|
||||||
preamble += "for i := range " + p.ParameterName + "{\n"
|
preamble += "for i := range " + p.ParameterName + "{\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user