Draglists, implemented as up-down preference lists as in GTK.
[sgt/putty] / int64.c
diff --git a/int64.c b/int64.c
index da7b4c3..8a1cda1 100644 (file)
--- a/int64.c
+++ b/int64.c
@@ -5,10 +5,9 @@
  */
 
 #include <assert.h>
+#include <string.h>
 
-typedef struct {
-    unsigned long hi, lo;
-} uint64, int64;
+#include "int64.h"
 
 uint64 uint64_div10(uint64 x, int *remainder)
 {
@@ -37,11 +36,11 @@ void uint64_decimal(uint64 x, char *buffer)
     int start = 20;
     int d;
 
-    while (x.hi || x.lo) {
+    do {
        x = uint64_div10(x, &d);
        assert(start > 0);
        buf[--start] = d + '0';
-    }
+    } while (x.hi || x.lo);
 
     memcpy(buffer, buf + start, sizeof(buf) - start);
     buffer[sizeof(buf) - start] = '\0';
@@ -69,3 +68,12 @@ uint64 uint64_add32(uint64 x, unsigned long y)
     yy.lo = y;
     return uint64_add(x, yy);
 }
+
+int uint64_compare(uint64 x, uint64 y)
+{
+    if (x.hi != y.hi)
+       return x.hi < y.hi ? -1 : +1;
+    if (x.lo != y.lo)
+       return x.lo < y.lo ? -1 : +1;
+    return 0;
+}