Fix 64-bit-ness in Database.xs
authorChip Black <bytex64@bytex64.net>
Sat, 16 Nov 2013 04:26:48 +0000 (22:26 -0600)
committerChip Black <bytex64@bytex64.net>
Sat, 29 Mar 2014 03:56:23 +0000 (22:56 -0500)
lib/perl/Blerg-Database/Database.xs

index df1c463..04406c8 100644 (file)
@@ -49,19 +49,25 @@ int _close(struct blerg *ptr)
     OUTPUT:
         RETVAL
 
-int _store(struct blerg *ptr, const char *data, int length(data))
+const char * _store(struct blerg *ptr, const char *data, int length(data))
     PROTOTYPE: $$
-    CODE:
-        RETVAL = blerg_store(ptr, data, XSauto_length_of_data);
-    OUTPUT:
-        RETVAL
+    INIT:
+        uint64_t record;
+        char buf[21];
+        int n;
+    PPCODE:
+        record = blerg_store(ptr, data, XSauto_length_of_data);
+        n = snprintf(buf, 21, "%llu", record);
+        XPUSHs(sv_2mortal(newSVpv(buf, n)));
 
-const char * _fetch(struct blerg *ptr, int record)
+const char * _fetch(struct blerg *ptr, const char *str_record)
     INIT:
+        uint64_t record;
         char *buf;
         int buflen;
         int n;
     PPCODE:
+        record = strtoull(str_record, NULL, 0);
         n = blerg_fetch(ptr, record, &buf, &buflen);
         if (!n) {
             XSRETURN_UNDEF;
@@ -79,8 +85,11 @@ const char * _get_record_count(struct blerg *ptr)
         n = snprintf(buf, 21, "%llu", count);
         XPUSHs(sv_2mortal(newSVpv(buf, n)));
 
-time_t _get_timestamp(struct blerg *ptr, int record)
+time_t _get_timestamp(struct blerg *ptr, const char *str_record)
+    INIT:
+        uint64_t record;
     CODE:
+        record = strtoull(str_record, NULL, 0);
         RETVAL = blerg_get_timestamp(ptr, record);
     OUTPUT:
         RETVAL