[Groonga-mysql-commit] mroonga/mroonga at 3abdd82 [master] Fix memory leaks

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Oct 29 13:37:44 JST 2015


Kouhei Sutou	2015-10-29 13:37:44 +0900 (Thu, 29 Oct 2015)

  New Revision: 3abdd8222f75f0601f0e8c36419b9272c1ed7a0e
  https://github.com/mroonga/mroonga/commit/3abdd8222f75f0601f0e8c36419b9272c1ed7a0e

  Message:
    Fix memory leaks

  Modified files:
    lib/mrn_database_manager.cpp

  Modified: lib/mrn_database_manager.cpp (+7 -2)
===================================================================
--- lib/mrn_database_manager.cpp    2015-10-29 11:10:39 +0900 (073f679)
+++ lib/mrn_database_manager.cpp    2015-10-29 13:37:44 +0900 (e1f67aa)
@@ -155,7 +155,7 @@ namespace mrn {
     Database *db = NULL;
     memcpy(&db, db_address, sizeof(Database *));
     if (db) {
-      db->close();
+      delete db;
     }
 
     grn_hash_delete_by_id(ctx_, cache_, id, NULL);
@@ -194,11 +194,16 @@ namespace mrn {
       if (id != GRN_ID_NIL) {
         grn_hash_delete_by_id(ctx_, cache_, id, NULL);
       }
+      delete db;
+      GRN_LOG(ctx_, GRN_LOG_ERROR,
       DBUG_RETURN(true);
     } else {
       GRN_LOG(ctx_, GRN_LOG_ERROR,
               "failed to drop database: <%s>: <%s>",
               mapper.db_path(), ctx_->errbuf);
+      if (id == GRN_ID_NIL) {
+        delete db;
+      }
       DBUG_RETURN(false);
     }
   }
@@ -235,7 +240,7 @@ namespace mrn {
         my_message(error, ctx_->errbuf, MYF(0));
         break;
       }
-      db->close();
+      delete db;
     }
     grn_hash_cursor_close(ctx_, cursor);
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-mysql-commit mailing list
Back to archive index