Skip to content

Commit 1ea37a7

Browse files
author
Ivan Dlugos
committed
expose OBX_bytes_wrapper.managedCopyOf() align parameter
1 parent 8e15f36 commit 1ea37a7

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/src/bindings/flatbuffers.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class OBXFlatbuffersManager<T> {
107107
});
108108

109109
var endOffset = builder.endTable();
110-
return OBX_bytes_wrapper.managedCopyOf(builder.finish(endOffset));
110+
return OBX_bytes_wrapper.managedCopyOf(builder.finish(endOffset),
111+
align: true);
111112
}
112113

113114
T unmarshal(Pointer<Uint8> dataPtr, int length) {

lib/src/bindings/structs.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,11 @@ class OBX_bytes_wrapper {
4949

5050
/// Returns a pointer to OBX_bytes with copy of the passed data.
5151
/// Warning: this creates two unmanaged pointers which must be freed manually: OBX_bytes.freeManaged(result).
52-
OBX_bytes_wrapper.managedCopyOf(Uint8List data)
52+
/// ObjectBox requires object data to be aligned to the length of 4.
53+
OBX_bytes_wrapper.managedCopyOf(Uint8List data, {/*required*/ bool align})
5354
: _cBytes = allocate<OBX_bytes>() {
5455
final bytes = _cBytes.ref;
5556

56-
// ObjectBox requires data to be aligned to the length of 4
57-
const align = true;
5857
bytes.size = align ? ((data.length + 3.0) ~/ 4.0) * 4 : data.length;
5958

6059
// NOTE: currently there's no way to get access to the underlying memory of Uint8List to avoid a copy.

lib/src/sync.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class SyncClient {
135135
/// Configure authentication credentials.
136136
/// The accepted [SyncCredentials] type depends on your sync-server configuration.
137137
void setCredentials(SyncCredentials creds) {
138-
final cCreds = OBX_bytes_wrapper.managedCopyOf(creds._data);
138+
final cCreds = OBX_bytes_wrapper.managedCopyOf(creds._data, align: false);
139139
try {
140140
checkObx(bindings.obx_sync_credentials(
141141
ptr,

0 commit comments

Comments
 (0)