[Groonga-commit] groonga/groonga at 38fd1fb [master] windows tsv: use grn_strcpy()

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Apr 18 21:58:20 JST 2015


Kouhei Sutou	2015-04-18 21:58:20 +0900 (Sat, 18 Apr 2015)

  New Revision: 38fd1fb62c043d6ce9c49a4e04f367aaaebf475e
  https://github.com/groonga/groonga/commit/38fd1fb62c043d6ce9c49a4e04f367aaaebf475e

  Message:
    windows tsv: use grn_strcpy()

  Modified files:
    plugins/query_expanders/tsv.c

  Modified: plugins/query_expanders/tsv.c (+5 -9)
===================================================================
--- plugins/query_expanders/tsv.c    2015-04-18 17:07:40 +0900 (479854b)
+++ plugins/query_expanders/tsv.c    2015-04-18 21:58:20 +0900 (35a77eb)
@@ -41,24 +41,20 @@
 static grn_hash *synonyms = NULL;
 
 #ifdef WIN32
-static char *win32_synonyms_file = NULL;
+static char win32_synonyms_file[MAX_PATH] = "";
 const char *
 get_system_synonyms_file(void)
 {
-  if (!win32_synonyms_file) {
+  if (win32_synonyms_file[0] == '\0') {
     const char *base_dir;
     const char *relative_path = GRN_QUERY_EXPANDER_TSV_RELATIVE_SYNONYMS_FILE;
-    char *synonyms_file;
     size_t base_dir_length;
 
     base_dir = grn_plugin_win32_base_dir();
     base_dir_length = strlen(base_dir);
-    synonyms_file =
-      malloc(base_dir_length + strlen("/") + strlen(relative_path) + 1);
-    strcpy(synonyms_file, base_dir);
-    strcat(synonyms_file, "/");
-    strcat(synonyms_file, relative_path);
-    win32_synonyms_file = synonyms_file;
+    grn_strcpy(win32_synonyms_file, MAX_PATH, base_dir);
+    strcat(win32_synonyms_file_entity, "/");
+    strcat(win32_synonyms_file_entity, relative_path);
   }
   return win32_synonyms_file;
 }
-------------- next part --------------
HTML����������������������������...
Descargar 



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