I have a C function, that is calling a go-Function with an char array parameter. The go-Function has to modify the content of the parameter. How to accomplish this?
void cFunction() {
char buffer[9] = "aaabbbccc"; // 9 is in this case correct, it is not a null-terminated-string
goFunction(buffer);
// buffer shall be modified
}
func goFunction(cBuffer *C.char) {
// how to modify 3-5?
//strncpy(cBuffer+3, "XXX")
}
EDIT: to be more precise. I have to implement a callbackfunction, that accepts an outparameter, which I have to manipulate.
void callback(char outbuffer[9]) {
goFunction(outbuffer);
}
as I understand Franks answer, I should do something like
allocate new go buffer
convert C buffer to go buffer
manipulate go buffer
allocate new C buffer
convert go buffer to C buffer
memcpy C buffer into outbuffer
That is too much allocation and conversion for my taste