Permalink
Browse files

fix bug for info

  • Loading branch information...
believe3301 committed Sep 18, 2012
1 parent c65e142 commit 2fd4d8be2cfab83b1c5ef5399d4f804a7c286e49
Showing with 3 additions and 3 deletions.
  1. +1 −1 binding/lru_jni.c
  2. +2 −2 lru.c
View
@@ -9,7 +9,6 @@ Java_com_feinno_kv_MemDB_open(JNIEnv *jenv, jobject clazz, jlong bufsize, jint h
(void) jenv;
lru *l = lru_init((uint64_t) bufsize, (unsigned int) hashpower);
-
return (jlong)(intptr_t)l;
}
@@ -106,6 +105,7 @@ Java_com_feinno_kv_MemDB_info(JNIEnv *jenv, jobject clazz, jlong ptr, jbyteArray
buf = (char*)(*jenv)->GetByteArrayElements(jenv, jbuf, 0);
if (buf) {
stat_print(l, buf, (int)jblen);
+ (*jenv)->ReleaseByteArrayElements(jenv, jbuf, (jbyte*)buf, 0);
}
}
View
4 lru.c
@@ -18,10 +18,10 @@ lru_init(const uint64_t maxbytes, const unsigned int hashpower)
fprintf(stderr, "hash power must less than 32.\n");
return NULL;
} else {
- l->hashpower = hashpower <= 0 ? HASH_POWER_DEFAULT: hashpower;
+ l->hashpower = hashpower == 0 ? HASH_POWER_DEFAULT: hashpower;
}
- l->max_bytes = maxbytes <=0 ? MAXBYTE_DEDAULT: maxbytes;
+ l->max_bytes = maxbytes ==0 ? MAXBYTE_DEDAULT: maxbytes;
l->table = calloc(hashsize(l->hashpower), sizeof(void *));
if (l->table == NULL) {

0 comments on commit 2fd4d8b

Please sign in to comment.