/* * 次のレコードを読む。 * * === Return * String:: レコードのキー * Integer:: レコードのスコア */ static VALUE records_next(VALUE obj) { sen_records *recs; int keylen; char keybuf[256]; char *bufp; int score; VALUE key; Data_Get_Struct(obj, sen_records, recs); keylen = sen_records_next(recs, keybuf, sizeof(keybuf), &score); if (keylen == 0) return Qnil; if (keylen <= sizeof(keybuf)) { key = rb_str_new(keybuf, keylen-1); } else { bufp = xmalloc(keylen); sen_records_curr_key(recs, bufp, keylen); key = rb_str_new(bufp, keylen-1); xfree(bufp); } return rb_ary_new3(2, key, INT2NUM(score)); }