Skip to content

Commit 6788906

Browse files
p-lindbergCoreyKaylor
authored andcommitted
Fixed marshalling of size_t into nuint instead of int.
1 parent 2263fd5 commit 6788906

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/LightningDB.Tests/TransactionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public void can_get_transaction_id()
294294

295295
env.RunTransactionScenario((tx, _) =>
296296
{
297-
tx.Id.ShouldBeGreaterThan(0);
297+
tx.Id.ShouldBeGreaterThan((nuint)0);
298298
});
299299
}
300300

src/LightningDB/LightningCursor.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,11 @@ public MDBResultCode Renew(LightningTransaction txn)
521521
/// </summary>
522522
/// <param name="value">Output parameter where the duplicate count will be stored.</param>
523523
/// <returns>Returns <see cref="MDBResultCode"/></returns>
524-
public MDBResultCode Count(out int value)
524+
public MDBResultCode Count(out long value)
525525
{
526-
return mdb_cursor_count(_handle, out value);
526+
var result = mdb_cursor_count(_handle, out var count);
527+
value = (long)count;
528+
return result;
527529
}
528530

529531
private bool ShouldCloseCursor()

src/LightningDB/LightningTransaction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ public Stats GetStats(LightningDatabase db)
422422
/// <summary>
423423
/// Gets the transaction ID.
424424
/// </summary>
425-
public int Id => mdb_txn_id(_handle);
425+
public nuint Id => mdb_txn_id(_handle);
426426

427427
/// <summary>
428428
/// Compares two data items according to the database's key comparison function.

src/LightningDB/Native/Lmdb.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public static partial class Lmdb
229229
/// <returns>The transaction ID</returns>
230230
[LibraryImport(MDB_DLL_NAME)]
231231
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
232-
public static partial int mdb_txn_id(nint txn);
232+
public static partial nuint mdb_txn_id(nint txn);
233233

234234
/// <summary>
235235
/// Commits all the operations of a transaction into the database.
@@ -388,7 +388,7 @@ public static partial class Lmdb
388388
/// <returns>A result code indicating success or failure</returns>
389389
[LibraryImport(MDB_DLL_NAME)]
390390
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
391-
public static partial MDBResultCode mdb_cursor_count(nint cursor, out int countp);
391+
public static partial MDBResultCode mdb_cursor_count(nint cursor, out nuint countp);
392392

393393
/// <summary>
394394
/// Stores key/data pairs in a database.
@@ -872,7 +872,7 @@ internal static MDBResultCode mdb_env_open(nint env, string path, EnvironmentOpe
872872
/// <param name="txn">A transaction handle</param>
873873
/// <returns>The transaction ID</returns>
874874
[DllImport(MDB_DLL_NAME, CallingConvention = CallingConvention.Cdecl)]
875-
public static extern int mdb_txn_id(nint txn);
875+
public static extern nuint mdb_txn_id(nint txn);
876876

877877
/// <summary>
878878
/// Commits all the operations of a transaction into the database.
@@ -1040,7 +1040,7 @@ public static MDBResultCode mdb_env_copy2(nint env, string path, EnvironmentCopy
10401040
/// <param name="countp">Address where the count will be stored</param>
10411041
/// <returns>A result code indicating success or failure</returns>
10421042
[DllImport(MDB_DLL_NAME, CallingConvention = CallingConvention.Cdecl)]
1043-
public static extern MDBResultCode mdb_cursor_count(nint cursor, out int countp);
1043+
public static extern MDBResultCode mdb_cursor_count(nint cursor, out nuint countp);
10441044

10451045
/// <summary>
10461046
/// Stores key/data pairs in a database.

0 commit comments

Comments
 (0)