Anonymous avatar 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)
 	}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.