static int rdb_vsiz(lua_State *L){ TCRDB *rdb = rdb_getrdb(L, 1); size_t ksiz = 0; const char *key = rdb_getarg(L, 2, &ksiz); int vsiz = tcrdbvsiz(rdb, key, ksiz); lua_pushnumber(L, vsiz); return 1; }
/* vsiz */ JNIEXPORT jint JNICALL Java_tokyotyrant_TCRDB_vsiz (JNIEnv *env, jobject self, jbyteArray pkey){ if(!pkey){ throwillarg(env); return 0; } TCRDB *tcrdb = (TCRDB *)(intptr_t)(*env)->GetLongField(env, self, tcrdb_fid_ptr); jboolean ick; jbyte *kbuf = (*env)->GetByteArrayElements(env, pkey, &ick); if(!kbuf){ throwoutmem(env); return 0; } int ksiz = (*env)->GetArrayLength(env, pkey); int rv = tcrdbvsiz(tcrdb, kbuf, ksiz); if(ick) (*env)->ReleaseByteArrayElements(env, pkey, kbuf, JNI_ABORT); return rv; }
static VALUE mTokyoMessenger_check(VALUE vself, VALUE vkey){ TCRDB *db = mTokyoMessenger_getdb(vself); vkey = StringValueEx(vkey); return tcrdbvsiz(db, RSTRING_PTR(vkey), RSTRING_LEN(vkey)) >= 0 ? Qtrue : Qfalse; }