[Groonga-commit] groonga/groonga [master] modified grn::dat::CursorFactory to return NULL when `trie' is an invalid reference.

Back to archive index

null+****@clear***** null+****@clear*****
2011年 7月 4日 (月) 17:18:05 JST


Susumu Yata	2011-07-04 08:18:05 +0000 (Mon, 04 Jul 2011)

  New Revision: 16aadf1495c631933470f56e6d07b6ea7f548c52

  Log:
    modified grn::dat::CursorFactory to return NULL when `trie' is an invalid reference.

  Modified files:
    lib/dat/cursor-factory.cpp

  Modified: lib/dat/cursor-factory.cpp (+16 -8)
===================================================================
--- lib/dat/cursor-factory.cpp    2011-07-02 05:19:25 +0000 (1bcb5e2)
+++ lib/dat/cursor-factory.cpp    2011-07-04 08:18:05 +0000 (9cf75b2)
@@ -21,8 +21,10 @@ Cursor *CursorFactory::open(const Trie &trie,
       IdCursor *cursor = new (std::nothrow) IdCursor;
       GRN_DAT_THROW_IF(MEMORY_ERROR, cursor == NULL);
       try {
-        cursor->open(trie, String(min_ptr, min_length),
-                     String(max_ptr, max_length), offset, limit, flags);
+        if (&trie != NULL) {
+          cursor->open(trie, String(min_ptr, min_length),
+                       String(max_ptr, max_length), offset, limit, flags);
+        }
       } catch (...) {
         delete cursor;
         throw;
@@ -33,8 +35,10 @@ Cursor *CursorFactory::open(const Trie &trie,
       KeyCursor *cursor = new (std::nothrow) KeyCursor;
       GRN_DAT_THROW_IF(MEMORY_ERROR, cursor == NULL);
       try {
-        cursor->open(trie, String(min_ptr, min_length),
-                     String(max_ptr, max_length), offset, limit, flags);
+        if (&trie != NULL) {
+          cursor->open(trie, String(min_ptr, min_length),
+                       String(max_ptr, max_length), offset, limit, flags);
+        }
       } catch (...) {
         delete cursor;
         throw;
@@ -45,8 +49,10 @@ Cursor *CursorFactory::open(const Trie &trie,
       CommonPrefixCursor *cursor = new (std::nothrow) CommonPrefixCursor;
       GRN_DAT_THROW_IF(MEMORY_ERROR, cursor == NULL);
       try {
-        cursor->open(trie, String(max_ptr, max_length), min_length,
-                     offset, limit, flags);
+        if (&trie != NULL) {
+          cursor->open(trie, String(max_ptr, max_length), min_length,
+                       offset, limit, flags);
+        }
       } catch (...) {
         delete cursor;
         throw;
@@ -57,8 +63,10 @@ Cursor *CursorFactory::open(const Trie &trie,
       PredictiveCursor *cursor = new (std::nothrow) PredictiveCursor;
       GRN_DAT_THROW_IF(MEMORY_ERROR, cursor == NULL);
       try {
-        cursor->open(trie, String(min_ptr, min_length),
-                     offset, limit, flags);
+        if (&trie != NULL) {
+          cursor->open(trie, String(min_ptr, min_length),
+                       offset, limit, flags);
+        }
       } catch (...) {
         delete cursor;
         throw;




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