Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MB-7297 Use size_t for python wrapping for 32-bit support

The couchstore/couch_db.h uses size_t for several struct fields, and
size_t can be either 32-bits or 64-bits, depending on platform.
So, instead of c_ulonglong, use c_size_t for those fields.

Here, we assume sizeof(off_t) == sizeof(size_t). Not a 100%
bulletproof assumption, but it seems to work on tests.

Additionally, use uint64_t for the couchstore_open_db() flags
parameter rather than the platform-specific int.

Change-Id: I36898d0260d44d57fe16ff7e16c7759c4686b4e4
Reviewed-on: http://review.couchbase.org/22969
Tested-by: Steve Yen <steve.yen@gmail.com>
Reviewed-by: Aaron Miller <apage43@ninjawhale.com>
Tested-by: Aaron Miller <apage43@ninjawhale.com>
  • Loading branch information...
commit e99a4e8f40365c1f431050bdbae371cb8d3d86aa 1 parent 08577b1
@steveyen steveyen authored Farshid Ghods committed
Showing with 4 additions and 4 deletions.
  1. +4 −4 python/couchstore.py
View
8 python/couchstore.py
@@ -65,7 +65,7 @@ def _toString (key):
### INTERNAL STRUCTS:
class SizedBuf (Structure):
- _fields_ = [("buf", POINTER(c_char)), ("size", c_ulonglong)]
+ _fields_ = [("buf", POINTER(c_char)), ("size", c_size_t)]
def __init__(self, string):
if string != None:
@@ -90,7 +90,7 @@ class DocInfoStruct (Structure):
("deleted", c_int),
("content_meta", c_ubyte),
("bp", c_ulonglong),
- ("size", c_ulonglong) ]
+ ("size", c_size_t) ]
class LocalDocStruct (Structure):
_fields_ = [("id", SizedBuf),
@@ -103,7 +103,7 @@ class DbInfoStruct (Structure):
("doc_count", c_ulonglong),
("deleted_count", c_ulonglong),
("space_used", c_ulonglong),
- ("header_position", c_ulonglong) ]
+ ("header_position", c_size_t) ]
### DOCUMENT INFO CLASS:
@@ -223,7 +223,7 @@ def __init__ (self, path, mode =None):
flags = 0
db = c_void_p()
- _check(_lib.couchstore_open_db(path, flags, byref(db)))
+ _check(_lib.couchstore_open_db(path, c_uint64(flags), byref(db)))
self._as_parameter_ = db
self.path = path
Please sign in to comment.
Something went wrong with that request. Please try again.