[Groonga-commit] groonga/groonga [master] fixed errors of grn_dat.

Back to archive index

null+****@clear***** null+****@clear*****
2011年 11月 10日 (木) 10:57:24 JST


Susumu Yata	2011-11-10 01:57:24 +0000 (Thu, 10 Nov 2011)

  New Revision: 6cab10a254fb9ce8144a10d9e8e9afb389a6f748

  Merged 770d028: Merge branch 'master' of github.com:groonga/groonga

  Log:
    fixed errors of grn_dat.

  Modified files:
    lib/dat.cpp

  Modified: lib/dat.cpp (+12 -8)
===================================================================
--- lib/dat.cpp    2011-11-10 01:37:34 +0000 (abf2473)
+++ lib/dat.cpp    2011-11-10 01:57:24 +0000 (7f626c4)
@@ -730,14 +730,13 @@ grn_dat_cursor_close(grn_ctx *ctx, grn_dat_cursor *c)
 int
 grn_dat_cursor_get_key(grn_ctx *ctx, grn_dat_cursor *c, const void **key)
 {
-  if (!c || !c->cursor) {
-    return 0;
-  }
 #ifndef WIN32
-  const grn::dat::Key &key = static_cast<const grn::dat::Key *>(c->key);
-  if (key.is_valid()) {
-    *key = key.ptr();
-    return (int)key.length();
+  if (c) {
+    const grn::dat::Key &key_ref = *static_cast<const grn::dat::Key *>(c->key);
+    if (key_ref.is_valid()) {
+      *key = key_ref.ptr();
+      return (int)key_ref.length();
+    }
   }
 #endif
   return 0;
@@ -749,10 +748,15 @@ grn_dat_cursor_delete(grn_ctx *ctx, grn_dat_cursor *c,
 {
   if (!c || !c->cursor) {
     return GRN_INVALID_ARGUMENT;
+  } else if (!grn_dat_open_trie_if_needed(ctx, c->dat)) {
+    return ctx->rc;
   }
 #ifndef WIN32
+  grn::dat::Trie * const trie = static_cast<grn::dat::Trie *>(c->dat->trie);
+  if (!trie) {
+    return GRN_INVALID_ARGUMENT;
+  }
   try {
-    grn::dat::Trie * const trie = static_cast<const grn::dat::Trie *>(c->cursor->dat->trie);
     if (trie->remove(c->curr_rec)) {
       return GRN_SUCCESS;
     }




Groonga-commit メーリングリストの案内
Back to archive index