[Groonga-commit] groonga/groonga at 2c12985 [master] Use free(ptr) for GRN_REALLOC(ptr, 0)

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Oct 23 17:27:20 JST 2013


Kouhei Sutou	2013-10-23 17:27:20 +0900 (Wed, 23 Oct 2013)

  New Revision: 2c12985011003baa0637456b9fa1f35cc9e69f6c
  https://github.com/groonga/groonga/commit/2c12985011003baa0637456b9fa1f35cc9e69f6c

  Message:
    Use free(ptr) for GRN_REALLOC(ptr, 0)
    
    Because "realloc(ptr, 0) == free(ptr)" is true only in glibc. Use
    free(ptr) is more portable.

  Modified files:
    lib/ctx.c

  Modified: lib/ctx.c (+1 -9)
===================================================================
--- lib/ctx.c    2013-10-23 17:27:27 +0900 (575f834)
+++ lib/ctx.c    2013-10-23 17:27:20 +0900 (d5d7588)
@@ -2701,16 +2701,8 @@ grn_realloc_default(grn_ctx *ctx, void *ptr, size_t size, const char* file, int
     if (!ptr) { return NULL; }
     grn_alloc_info_check(ptr);
     GRN_ADD_ALLOC_COUNT(-1);
-#if defined(__FreeBSD__) || defined(__APPLE__)
     free(ptr);
-    return NULL;
-#else /* defined(__FreeBSD__) || defined(__APPLE__) */
-    res = realloc(ptr, size);
-    if (res) {
-      GRN_LOG(ctx, GRN_LOG_ALERT, "realloc(%p,%zu)=%p (%s:%d) <%d>", ptr, size, res, file, line, alloc_count);
-      // grn_free(ctx, res, file, line);
-    }
-#endif /* __FreeBSD__ */
+    res = NULL;
   }
   return res;
 }
-------------- next part --------------
HTML����������������������������...
Download 



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