Пример #1
0
func (c *CGoSystem) BeginReadData(consumerHandle uint32, flags uint32) (result uint32, buf []byte) {
	var buffer unsafe.Pointer
	var bufferNumBytes C.uint32_t
	r := C.MojoBeginReadData(C.MojoHandle(consumerHandle), &buffer, &bufferNumBytes, C.MojoReadDataFlags(flags))
	if r != C.MOJO_RESULT_OK {
		return uint32(r), nil
	}
	return uint32(r), unsafeByteSlice(buffer, int(bufferNumBytes))
}
Пример #2
0
func (c *CGoSystem) ReadData(consumerHandle uint32, flags uint32) (result uint32, buf []byte) {
	var numBytes C.uint32_t
	if r := C.MojoReadData(C.MojoHandle(consumerHandle), nil, &numBytes, C.MOJO_READ_DATA_FLAG_QUERY); r != C.MOJO_RESULT_OK {
		return uint32(r), nil
	}
	if numBytes == 0 {
		return uint32(C.MOJO_RESULT_OK), nil
	}
	buf = make([]byte, int(numBytes))
	r := C.MojoReadData(C.MojoHandle(consumerHandle), unsafe.Pointer(&buf[0]), &numBytes, C.MojoReadDataFlags(flags))
	buf = buf[0:int(numBytes)]
	return uint32(r), buf
}