git » nmdb » commit 051bc59

Fix the user types in D bindings.

author Alberto Bertogli
2007-03-31 23:13:28 UTC
committer Alberto Bertogli
2007-03-31 23:13:28 UTC
parent 1c023099de1bca18d7e9bbb00234f40e86c29119

Fix the user types in D bindings.

Instead of defining size_t and ssize_t ourselves, use size_t and ptrdiff_t
which are guaranteed to have the same semantics that C in all platforms.

d/nmdb.d +2 -2
d/nmdb_ll.d +4 -6

diff --git a/d/nmdb.d b/d/nmdb.d
index 8d4dc13..b734f7d 100644
--- a/d/nmdb.d
+++ b/d/nmdb.d
@@ -41,7 +41,7 @@ class DB
 
 	private char[] do_get(char[] key, int mode)
 	{
-		long size;
+		ptrdiff_t size;
 		ubyte* k = cast(ubyte *) key.ptr;
 		auto v = new char[256];
 
@@ -61,7 +61,7 @@ class DB
 			throw new Exception("Can't get value");
 		}
 
-		return v[0 .. cast(ulong) size];
+		return v[0 .. cast(size_t) size];
 	}
 
 	private void do_set(char[] key, char[] val, int mode)
diff --git a/d/nmdb_ll.d b/d/nmdb_ll.d
index 8750eea..e3ee112 100644
--- a/d/nmdb_ll.d
+++ b/d/nmdb_ll.d
@@ -19,11 +19,9 @@ module nmdb_ll;
  */
 
 version (X86_64) {
-	/* The following has been generated on a Pentium D running Gentoo in
-	 * 64 bit mode. It should be the same on all Linux amd64 boxes. */
+	/* Generated on a Pentium D running Gentoo in 64 bits mode. It should
+	 * be the same on all Linux amd64 boxes. */
 	alias ubyte[16] nmdb_t;
-	alias ulong size_t;
-	alias long ssize_t;
 }
 
 
@@ -34,9 +32,9 @@ extern (C) nmdb_t *nmdb_init(int port);
 extern (C) int nmdb_add_server(nmdb_t *db, int port);
 extern (C) int nmdb_free(nmdb_t *db);
 
-extern (C) ssize_t nmdb_get(nmdb_t *db, ubyte *key, size_t ksize,
+extern (C) ptrdiff_t nmdb_get(nmdb_t *db, ubyte *key, size_t ksize,
 		ubyte *val, size_t vsize);
-extern (C) ssize_t nmdb_cache_get(nmdb_t *db, ubyte *key, size_t ksize,
+extern (C) ptrdiff_t nmdb_cache_get(nmdb_t *db, ubyte *key, size_t ksize,
 		ubyte *val, size_t vsize);
 
 extern (C) int nmdb_set(nmdb_t *db, ubyte *key, size_t ksize,