[Groonga-commit] groonga/grnxx at f5cf886 [master] Update RecordSet to report memory allocation failure.

Back to archive index

susumu.yata null+****@clear*****
Wed Jul 16 11:42:30 JST 2014


susumu.yata	2014-07-16 11:42:30 +0900 (Wed, 16 Jul 2014)

  New Revision: f5cf886620b690ed8798c8561e0922c0edb9ca1d
  https://github.com/groonga/grnxx/commit/f5cf886620b690ed8798c8561e0922c0edb9ca1d

  Message:
    Update RecordSet to report memory allocation failure.

  Added files:
    lib/grnxx/report.cpp
  Modified files:
    include/grnxx/record.hpp
    lib/grnxx/Makefile.am

  Modified: include/grnxx/record.hpp (+6 -2)
===================================================================
--- include/grnxx/record.hpp    2014-07-16 11:22:09 +0900 (920e7fe)
+++ include/grnxx/record.hpp    2014-07-16 11:42:30 +0900 (c826d1a)
@@ -15,6 +15,7 @@ struct Record {
   Record(Int row_id, Float score) : row_id(row_id), score(score) {}
 };
 
+// TODO: RecordSet should be reimplemented not to use std::vector?
 class RecordSet {
  public:
   RecordSet() : records_() {}
@@ -35,7 +36,7 @@ class RecordSet {
       records_.push_back(record);
       return true;
     } catch (...) {
-      // TODO: Error report should be written in .cpp file.
+      report_error(error);
       return false;
     }
   }
@@ -64,7 +65,7 @@ class RecordSet {
       records_.resize(size);
       return true;
     } catch (...) {
-      // TODO: Error report should be written in .cpp file.
+      report_error(error);
       return false;
     }
   }
@@ -76,6 +77,9 @@ class RecordSet {
 
  private:
   std::vector<Record> records_;
+
+  // Report a no memory error.
+  void report_error(Error *error);
 };
 
 }  // namespace grnxx

  Modified: lib/grnxx/Makefile.am (+1 -0)
===================================================================
--- lib/grnxx/Makefile.am    2014-07-16 11:22:09 +0900 (8050317)
+++ lib/grnxx/Makefile.am    2014-07-16 11:42:30 +0900 (713d9d0)
@@ -16,6 +16,7 @@ libgrnxx_la_SOURCES =			\
 	index.cpp			\
 	library.cpp			\
 	name.cpp			\
+	report.cpp			\
 	table.cpp			\
 	types.cpp
 

  Added: lib/grnxx/report.cpp (+11 -0) 100644
===================================================================
--- /dev/null
+++ lib/grnxx/report.cpp    2014-07-16 11:42:30 +0900 (929aea7)
@@ -0,0 +1,11 @@
+#include "grnxx/record.hpp"
+
+#include "grnxx/error.hpp"
+
+namespace grnxx {
+
+void RecordSet::report_error(Error *error) {
+  GRNXX_ERROR_SET(error, NO_MEMORY, "Memory allocation failed");
+}
+
+}  // namespace
-------------- next part --------------
HTML����������������������������...
Download 



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