serializeToPointedBytes function
Implementation
Tuple2<Pointer<UnsignedChar>, int> serializeToPointedBytes(
GeneratedMessage message,
) {
final bytes = message.writeToBuffer();
final ptr = malloc.allocate<UnsignedChar>(bytes.lengthInBytes);
try {
for (int index = 0; index < bytes.length; index++) {
ptr[index] = bytes[index];
}
} catch (_) {
malloc.free(ptr);
rethrow;
}
return Tuple2<Pointer<UnsignedChar>, int>(ptr, bytes.length);
}