[Groonga-commit] nroonga/nroonga [master] use std::string for command buffer in baton

Back to archive index

null+****@clear***** null+****@clear*****
2011年 11月 22日 (火) 17:13:18 JST


Yoji SHIDARA	2011-11-22 08:13:18 +0000 (Tue, 22 Nov 2011)

  New Revision: bc68b1fc5a567796a738b7547c2bd6c961ab99d3

  Log:
    use std::string for command buffer in baton

  Modified files:
    src/nroonga.cc
    src/nroonga.h

  Modified: src/nroonga.cc (+2 -5)
===================================================================
--- src/nroonga.cc    2011-11-22 06:52:34 +0000 (799063d)
+++ src/nroonga.cc    2011-11-22 08:13:18 +0000 (f10ed11)
@@ -57,7 +57,7 @@ void Database::CommandWork(uv_work_t* req) {
 
   grn_ctx_init(ctx, 0);
   grn_ctx_use(ctx, baton->database);
-  rc = grn_ctx_send(ctx, baton->command, baton->command_length, 0);
+  rc = grn_ctx_send(ctx, baton->command.c_str(), baton->command.size(), 0);
   if (rc < 0) {
     baton->error = 1;
     return;
@@ -99,7 +99,6 @@ void Database::CommandAfter(uv_work_t* req) {
       }
   }
   grn_ctx_fin(&baton->context);
-  delete baton->command;
   baton->callback.Dispose();
   delete baton;
 }
@@ -129,9 +128,7 @@ Handle<Value> Database::CommandString(const Arguments& args) {
   String::Utf8Value command(args[0]->ToString());
   baton->database = db->database;
 
-  baton->command = new char[command.length()];
-  memcpy(baton->command, *command, command.length());
-  baton->command_length = command.length();
+  baton->command = std::string(*command, command.length());
   uv_queue_work(uv_default_loop(),
       &baton->request,
       CommandWork,

  Modified: src/nroonga.h (+1 -2)
===================================================================
--- src/nroonga.h    2011-11-22 06:52:34 +0000 (e68d461)
+++ src/nroonga.h    2011-11-22 08:13:18 +0000 (88ce4f6)
@@ -25,8 +25,7 @@ class Database : ObjectWrap {
       char *result;
       unsigned int result_length;
 
-      char *command;
-      int command_length;
+      std::string command;
       grn_ctx context;
       grn_obj *database;
     };




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