[Groonga-commit] groonga/groonga at 6b4d883 [master] windows: use _strdup() on Windows

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Apr 15 23:37:10 JST 2015


Kouhei Sutou	2015-04-15 23:37:10 +0900 (Wed, 15 Apr 2015)

  New Revision: 6b4d8834243a2ef085b31a8830dc87b622a8d16d
  https://github.com/groonga/groonga/commit/6b4d8834243a2ef085b31a8830dc87b622a8d16d

  Message:
    windows: use _strdup() on Windows

  Modified files:
    include/groonga/portability.h
    lib/ctx.c
    lib/logger.c
    lib/util.c

  Modified: include/groonga/portability.h (+6 -0)
===================================================================
--- include/groonga/portability.h    2015-04-15 22:22:35 +0900 (02cbec0)
+++ include/groonga/portability.h    2015-04-15 23:37:10 +0900 (6de039a)
@@ -71,4 +71,10 @@
 # define grn_fopen(file, name, mode) (file) = fopen((name), (mode))
 #endif /* WIN32 */
 
+#ifdef WIN32
+# define grn_strdup_raw(string) _strdup((string))
+#else /* WIN32 */
+# define grn_strdup_raw(string) strdup((string))
+#endif /* WIN32 */
+
 #endif /* GROONGA_PORTABILITY_H */

  Modified: lib/ctx.c (+2 -2)
===================================================================
--- lib/ctx.c    2015-04-15 22:22:35 +0900 (a5fc477)
+++ lib/ctx.c    2015-04-15 23:37:10 +0900 (047b062)
@@ -2416,12 +2416,12 @@ grn_strdup_default(grn_ctx *ctx, const char *s, const char* file, int line, cons
 {
   if (!ctx) { return NULL; }
   {
-    char *res = strdup(s);
+    char *res = grn_strdup_raw(s);
     if (res) {
       GRN_ADD_ALLOC_COUNT(1);
       grn_alloc_info_add(res, file, line, func);
     } else {
-      if (!(res = strdup(s))) {
+      if (!(res = grn_strdup_raw(s))) {
         MERR("strdup(%p)=%p (%s:%d) <%d>", s, res, file, line, alloc_count);
       } else {
         GRN_ADD_ALLOC_COUNT(1);

  Modified: lib/logger.c (+3 -3)
===================================================================
--- lib/logger.c    2015-04-15 22:22:35 +0900 (48821f8)
+++ lib/logger.c    2015-04-15 23:37:10 +0900 (acb71b1)
@@ -164,7 +164,7 @@ grn_default_logger_set_path(const char *path)
   }
 
   if (path) {
-    default_logger_path = strdup(path);
+    default_logger_path = grn_strdup_raw(path);
   } else {
     default_logger_path = NULL;
   }
@@ -298,7 +298,7 @@ void
 grn_logger_init(void)
 {
   if (!default_logger_path) {
-    default_logger_path = strdup(GRN_LOG_PATH);
+    default_logger_path = grn_strdup_raw(GRN_LOG_PATH);
   }
   grn_memcpy(&current_logger, &default_logger, sizeof(grn_logger));
   CRITICAL_SECTION_INIT(default_logger_lock);
@@ -429,7 +429,7 @@ grn_default_query_logger_set_path(const char *path)
   }
 
   if (path) {
-    default_query_logger_path = strdup(path);
+    default_query_logger_path = grn_strdup_raw(path);
   } else {
     default_query_logger_path = NULL;
   }

  Modified: lib/util.c (+2 -2)
===================================================================
--- lib/util.c    2015-04-15 22:22:35 +0900 (80c3f32)
+++ lib/util.c    2015-04-15 23:37:10 +0900 (767b7c2)
@@ -1295,7 +1295,7 @@ grn_win32_base_dir(void)
                                                     absolute_dll_filename,
                                                     MAX_PATH);
     if (absolute_dll_filename_size == 0) {
-      win32_base_dir = strdup(".");
+      win32_base_dir = grn_strdup_raw(".");
     } else {
       DWORD ansi_dll_filename_size;
       ansi_dll_filename_size =
@@ -1303,7 +1303,7 @@ grn_win32_base_dir(void)
                             absolute_dll_filename, absolute_dll_filename_size,
                             NULL, 0, NULL, NULL);
       if (ansi_dll_filename_size == 0) {
-        win32_base_dir = strdup(".");
+        win32_base_dir = grn_strdup_raw(".");
       } else {
         char *path;
         win32_base_dir = malloc(ansi_dll_filename_size + 1);
-------------- next part --------------
HTML����������������������������...
다운로드 



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