Commits

Anonymous committed 661c070

improve increment to actually return the value

Comments (0)

Files changed (2)

 	return
 }
 
-func (kc *KCDB) IncrInt(key []byte, amount int64) (err os.Error) {
+func (kc *KCDB) IncrInt(key []byte, amount int64) (result int64, err os.Error) {
 	ckey := (*C.char)(unsafe.Pointer(&key[0]))
-	if C.kcdbincrint(kc.db, ckey, C.size_t(len(key)), C.int64_t(amount)) == 0 {
+	cresult := C.kcdbincrint(kc.db, ckey, C.size_t(len(key)), C.int64_t(amount))
+	if cresult == C.INT64_MIN {
 		err = kc.error()
+	} else {
+		result = int64(cresult)
 	}
 	return
 }
 	kc := newCabinet(t, test_db)
 	defer delCabinet(t, kc)
 
-	err := kc.IncrInt([]byte("numbers"), 6)
+	_, err := kc.IncrInt([]byte("numbers"), 6)
 	if err != nil {
 		t.Error("IncrInt(6): %s", err)
 	}
 		t.Errorf("IncrInt(6): expected 6 got %d", n)
 	}
 
-	err = kc.IncrInt([]byte("numbers"), 6)
+	_, err = kc.IncrInt([]byte("numbers"), 6)
 	if err != nil {
 		t.Error("IncrInt(6): %s", err)
 	}