[Groonga-commit] groonga/groonga at f912ff7 [master] Use XXX_init_from_env() naming rule

Back to archive index

Kouhei Sutou null+****@clear*****
Wed May 13 12:11:24 JST 2015


Kouhei Sutou	2015-05-13 12:11:24 +0900 (Wed, 13 May 2015)

  New Revision: f912ff743b79853a11139daee01f47c195991804
  https://github.com/groonga/groonga/commit/f912ff743b79853a11139daee01f47c195991804

  Message:
    Use XXX_init_from_env() naming rule

  Modified files:
    lib/ctx.c
    lib/grn_ii.h
    lib/grn_io.h
    lib/grn_mrb.h
    lib/grn_proc.h
    lib/ii.c
    lib/io.c
    lib/mrb.c
    lib/proc.c

  Modified: lib/ctx.c (+5 -23)
===================================================================
--- lib/ctx.c    2015-05-13 12:05:25 +0900 (585f68a)
+++ lib/ctx.c    2015-05-13 12:11:24 +0900 (0a36a53)
@@ -91,7 +91,12 @@ grn_init_from_env(void)
     }
   }
 
+  grn_mrb_init_from_env();
+  grn_ctx_impl_mrb_init_from_env();
+  grn_io_init_from_env();
+  grn_ii_init_from_env();
   grn_db_init_from_env();
+  grn_proc_init_from_env();
   grn_plugin_init_from_env();
 }
 
@@ -837,17 +842,10 @@ grn_init(void)
   grn_rc rc;
   grn_ctx *ctx = &grn_gctx;
   grn_init_from_env();
-  grn_ctx_impl_mrb_init_from_env();
   grn_logger_init();
   grn_query_logger_init();
   CRITICAL_SECTION_INIT(grn_glock);
   grn_gtick = 0;
-#ifdef GRN_WITH_MRUBY
-  if ((rc = grn_mrb_init())) {
-    GRN_LOG(ctx, GRN_LOG_ALERT, "grn_mrb_init failed (%d)", rc);
-    return rc;
-  }
-#endif
   ctx->next = ctx;
   ctx->prev = ctx;
   grn_ctx_init_internal(ctx, 0);
@@ -921,18 +919,6 @@ grn_init(void)
     return rc;
   }
   grn_ctx_impl_init(ctx);
-  if ((rc = grn_io_init())) {
-    GRN_LOG(ctx, GRN_LOG_ALERT, "grn_io_init failed (%d)", rc);
-    return rc;
-  }
-  if ((rc = grn_ii_init())) {
-    GRN_LOG(ctx, GRN_LOG_ALERT, "grn_ii_init failed (%d)", rc);
-    return rc;
-  }
-  if ((rc = grn_proc_init())) {
-    GRN_LOG(ctx, GRN_LOG_ALERT, "grn_proc_init failed (%d)", rc);
-    return rc;
-  }
   if ((rc = grn_plugins_init())) {
     GRN_LOG(ctx, GRN_LOG_ALERT, "grn_plugins_init failed (%d)", rc);
     return rc;
@@ -1049,11 +1035,7 @@ grn_fin(void)
   grn_tokenizers_fin();
   grn_normalizer_fin();
   grn_plugins_fin();
-  grn_proc_fin();
-  grn_ii_fin();
-  grn_io_fin();
   grn_ctx_fin(ctx);
-  grn_mrb_fin();
   grn_com_fin();
   GRN_LOG(ctx, GRN_LOG_NOTICE, "grn_fin (%d)", alloc_count);
   grn_logger_fin(ctx);

  Modified: lib/grn_ii.h (+2 -3)
===================================================================
--- lib/grn_ii.h    2015-05-13 12:05:25 +0900 (fcefd48)
+++ lib/grn_ii.h    2015-05-13 12:11:24 +0900 (6356af5)
@@ -1,5 +1,5 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009-2012 Brazil
+/* Copyright(C) 2009-2015 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -87,8 +87,7 @@ struct _grn_ii_updspec {
 
 typedef struct _grn_ii_updspec grn_ii_updspec;
 
-grn_rc grn_ii_init(void);
-grn_rc grn_ii_fin(void);
+void grn_ii_init_from_env(void);
 
 GRN_API grn_ii *grn_ii_create(grn_ctx *ctx, const char *path, grn_obj *lexicon,
                               uint32_t flags);

  Modified: lib/grn_io.h (+1 -2)
===================================================================
--- lib/grn_io.h    2015-05-13 12:05:25 +0900 (14f5e49)
+++ lib/grn_io.h    2015-05-13 12:11:24 +0900 (c0ea670)
@@ -350,8 +350,7 @@ uint32_t grn_io_detect_type(grn_ctx *ctx, const char *path);
 grn_rc grn_io_set_type(grn_io *io, uint32_t type);
 uint32_t grn_io_get_type(grn_io *io);
 
-grn_rc grn_io_init(void);
-grn_rc grn_io_fin(void);
+void grn_io_init_from_env(void);
 
 uint32_t grn_io_expire(grn_ctx *ctx, grn_io *io, int count_thresh, uint32_t limit);
 uint32_t grn_expire(grn_ctx *ctx, int count_thresh, uint32_t limit);

  Modified: lib/grn_mrb.h (+1 -2)
===================================================================
--- lib/grn_mrb.h    2015-05-13 12:05:25 +0900 (ecf8666)
+++ lib/grn_mrb.h    2015-05-13 12:11:24 +0900 (96c463e)
@@ -31,8 +31,7 @@ extern "C" {
 #endif
 
 #ifdef GRN_WITH_MRUBY
-grn_rc grn_mrb_init(void);
-grn_rc grn_mrb_fin(void);
+void grn_mrb_init_from_env(void);
 
 GRN_API mrb_value grn_mrb_eval(grn_ctx *ctx, const char *script, int script_length);
 GRN_API mrb_value grn_mrb_load(grn_ctx *ctx, const char *path);

  Modified: lib/grn_proc.h (+1 -2)
===================================================================
--- lib/grn_proc.h    2015-05-13 12:05:25 +0900 (cebbfca)
+++ lib/grn_proc.h    2015-05-13 12:11:24 +0900 (b75d110)
@@ -23,8 +23,7 @@
 extern "C" {
 #endif
 
-grn_rc grn_proc_init(void);
-grn_rc grn_proc_fin(void);
+void grn_proc_init_from_env(void);
 
 GRN_VAR const char *grn_document_root;
 void grn_db_init_builtin_query(grn_ctx *ctx);

  Modified: lib/ii.c (+2 -10)
===================================================================
--- lib/ii.c    2015-05-13 12:05:25 +0900 (beacc13)
+++ lib/ii.c    2015-05-13 12:11:24 +0900 (32d1ca3)
@@ -77,8 +77,8 @@
 static grn_bool grn_ii_cursor_set_min_enable = GRN_FALSE;
 static double grn_ii_select_too_many_index_match_ratio = -1;
 
-grn_rc
-grn_ii_init(void)
+void
+grn_ii_init_from_env(void)
 {
   {
     char grn_ii_cursor_set_min_enable_env[GRN_ENV_BUFFER_SIZE];
@@ -102,14 +102,6 @@ grn_ii_init(void)
         atof(grn_ii_select_too_many_index_match_ratio_env);
     }
   }
-
-  return GRN_SUCCESS;
-}
-
-grn_rc
-grn_ii_fin(void)
-{
-  return GRN_SUCCESS;
 }
 
 /* segment */

  Modified: lib/io.c (+2 -10)
===================================================================
--- lib/io.c    2015-05-13 12:05:25 +0900 (a78c7f2)
+++ lib/io.c    2015-05-13 12:11:24 +0900 (89fdfd6)
@@ -99,8 +99,8 @@ inline static int grn_msync(grn_ctx *ctx, void *start, size_t length);
 inline static grn_rc grn_pread(grn_ctx *ctx, fileinfo *fi, void *buf, size_t count, off_t offset);
 inline static grn_rc grn_pwrite(grn_ctx *ctx, fileinfo *fi, void *buf, size_t count, off_t offset);
 
-grn_rc
-grn_io_init(void)
+void
+grn_io_init_from_env(void)
 {
   char version_env[GRN_ENV_BUFFER_SIZE];
 
@@ -110,14 +110,6 @@ grn_io_init(void)
   if (version_env[0]) {
     grn_io_version_default = atoi(version_env);
   }
-
-  return GRN_SUCCESS;
-}
-
-grn_rc
-grn_io_fin(void)
-{
-  return GRN_SUCCESS;
 }
 
 static inline uint32_t

  Modified: lib/mrb.c (+3 -11)
===================================================================
--- lib/mrb.c    2015-05-13 12:05:25 +0900 (616fd2b)
+++ lib/mrb.c    2015-05-13 12:11:24 +0900 (2684718)
@@ -35,25 +35,17 @@
 #define BUFFER_SIZE 2048
 #define E_LOAD_ERROR (mrb_class_get(mrb, "LoadError"))
 
-#ifdef GRN_WITH_MRUBY
 static char grn_mrb_ruby_scripts_dir[GRN_ENV_BUFFER_SIZE];
 
-grn_rc
-grn_mrb_init(void)
+void
+grn_mrb_init_from_env(void)
 {
   grn_getenv("GRN_RUBY_SCRIPTS_DIR",
              grn_mrb_ruby_scripts_dir,
              GRN_ENV_BUFFER_SIZE);
-
-  return GRN_SUCCESS;
-}
-
-grn_rc
-grn_mrb_fin(void)
-{
-  return GRN_SUCCESS;
 }
 
+#ifdef GRN_WITH_MRUBY
 # ifdef WIN32
 static char *win32_ruby_scripts_dir = NULL;
 static char win32_ruby_scripts_dir_buffer[PATH_MAX];

  Modified: lib/proc.c (+2 -10)
===================================================================
--- lib/proc.c    2015-05-13 12:05:25 +0900 (1129329)
+++ lib/proc.c    2015-05-13 12:11:24 +0900 (00be429)
@@ -61,8 +61,8 @@ const char *grn_document_root = NULL;
 static double grn_between_too_many_index_match_ratio = 0.01;
 static double grn_in_values_too_many_index_match_ratio = 0.01;
 
-grn_rc
-grn_proc_init(void)
+void
+grn_proc_init_from_env(void)
 {
   {
     char grn_between_too_many_index_match_ratio_env[GRN_ENV_BUFFER_SIZE];
@@ -85,14 +85,6 @@ grn_proc_init(void)
         atof(grn_in_values_too_many_index_match_ratio_env);
     }
   }
-
-  return GRN_SUCCESS;
-}
-
-grn_rc
-grn_proc_fin(void)
-{
-  return GRN_SUCCESS;
 }
 
 /* bulk must be initialized grn_bulk or grn_msg */
-------------- next part --------------
HTML����������������������������...
Download 



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