apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject svn commit: r421373 - in /apr/apr/trunk: include/arch/win32/apr_arch_misc.h misc/win32/apr_app.c misc/win32/internal.c misc/win32/misc.c misc/win32/start.c
Date Wed, 12 Jul 2006 19:05:51 GMT
Author: jerenkrantz
Date: Wed Jul 12 12:05:51 2006
New Revision: 421373

URL: http://svn.apache.org/viewvc?rev=421373&view=rev
Log:
Protect usage of MS VC++ crtdbg.h functionality.

Originally titled: [patch 14/17] crtdbg.h

Submitted by: John Mark Vandenberg
Reviewed by: Justin Erenkrantz

Modified:
    apr/apr/trunk/include/arch/win32/apr_arch_misc.h
    apr/apr/trunk/misc/win32/apr_app.c
    apr/apr/trunk/misc/win32/internal.c
    apr/apr/trunk/misc/win32/misc.c
    apr/apr/trunk/misc/win32/start.c

Modified: apr/apr/trunk/include/arch/win32/apr_arch_misc.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/arch/win32/apr_arch_misc.h?rev=421373&r1=421372&r2=421373&view=diff
==============================================================================
--- apr/apr/trunk/include/arch/win32/apr_arch_misc.h (original)
+++ apr/apr/trunk/include/arch/win32/apr_arch_misc.h Wed Jul 12 12:05:51 2006
@@ -138,6 +138,37 @@
 #define ELSE_WIN_OS_IS_ANSI
 #endif /* WINNT */
 
+#if defined(_MSC_VER)
+#include "crtdbg.h"
+
+APR_INLINE void* apr_malloc_dbg(size_t size, const char* filename,
+                                int linenumber)
+{
+    return _malloc_dbg(size, _CRT_BLOCK, filename, linenumber);
+}
+
+APR_INLINE void* apr_realloc_dbg(void* userData, size_t newSize,
+                                 const char* filename, int linenumber)
+{
+    return _realloc_dbg(userData, newSize, _CRT_BLOCK, filename, linenumber);
+}
+
+#else
+
+APR_INLINE void* apr_malloc_dbg(size_t size, const char* filename,
+                                int linenumber)
+{
+    return malloc(size);
+}
+
+APR_INLINE void* apr_realloc_dbg(void* userData, size_t newSize,
+                                 const char* filename, int linenumber)
+{
+    return realloc(userData, newSize);
+}
+
+#endif  /* ! _MSC_VER */
+
 typedef enum {
     DLL_WINBASEAPI = 0,    // kernel32 From WinBase.h
     DLL_WINADVAPI = 1,     // advapi32 From WinBase.h

Modified: apr/apr/trunk/misc/win32/apr_app.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/misc/win32/apr_app.c?rev=421373&r1=421372&r2=421373&view=diff
==============================================================================
--- apr/apr/trunk/misc/win32/apr_app.c (original)
+++ apr/apr/trunk/misc/win32/apr_app.c Wed Jul 12 12:05:51 2006
@@ -35,7 +35,6 @@
 
 #include "apr_general.h"
 #include "ShellAPI.h"
-#include "crtdbg.h"
 #include "wchar.h"
 #include "apr_arch_file_io.h"
 #include "assert.h"
@@ -57,8 +56,8 @@
 
     dupenv = apr_wastrtoastr(&env, wenv, -1);
 
-    _environ = _malloc_dbg((dupenv + 1) * sizeof (char *), 
-                           _CRT_BLOCK, __FILE__, __LINE__ );
+    _environ = apr_malloc_dbg((dupenv + 1) * sizeof (char *),
+                              __FILE__, __LINE__ );
     memcpy(_environ, env, (dupenv + 1) * sizeof (char *));
 
     /* MSVCRT will attempt to maintain the wide environment calls

Modified: apr/apr/trunk/misc/win32/internal.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/misc/win32/internal.c?rev=421373&r1=421372&r2=421373&view=diff
==============================================================================
--- apr/apr/trunk/misc/win32/internal.c (original)
+++ apr/apr/trunk/misc/win32/internal.c Wed Jul 12 12:05:51 2006
@@ -18,7 +18,6 @@
 
 #include "apr_arch_misc.h"
 #include "apr_arch_file_io.h"
-#include <crtdbg.h>
 #include <assert.h>
 
 /* This module is the source of -static- helper functions that are
@@ -52,8 +51,8 @@
             ;
     }
 
-    newarr = _malloc_dbg((args + 1) * sizeof(char *),
-                         _CRT_BLOCK, __FILE__, __LINE__);
+    newarr = apr_malloc_dbg((args + 1) * sizeof(char *),
+                            __FILE__, __LINE__);
 
     for (arg = 0; arg < args; ++arg) {
         newarr[arg] = (void*)(wcslen(arr[arg]) + 1);
@@ -66,8 +65,8 @@
      * 4 ucs bytes will hold a wchar_t pair value (20 bits)
      */
     elesize = elesize * 3 + 1;
-    ele = elements = _malloc_dbg(elesize * sizeof(char), 
-                                 _CRT_BLOCK, __FILE__, __LINE__);
+    ele = elements = apr_malloc_dbg(elesize * sizeof(char),
+                                    __FILE__, __LINE__);
 
     for (arg = 0; arg < args; ++arg) {
         apr_size_t len = (apr_size_t)newarr[arg];
@@ -87,8 +86,8 @@
 
     /* Return to the free store if the heap realloc is the least bit optimized
      */
-    ele = _realloc_dbg(elements, ele - elements, 
-                       _CRT_BLOCK, __FILE__, __LINE__);
+    ele = apr_realloc_dbg(elements, ele - elements,
+                          __FILE__, __LINE__);
 
     if (ele != elements) {
         apr_size_t diff = ele - elements;

Modified: apr/apr/trunk/misc/win32/misc.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/misc/win32/misc.c?rev=421373&r1=421372&r2=421373&view=diff
==============================================================================
--- apr/apr/trunk/misc/win32/misc.c (original)
+++ apr/apr/trunk/misc/win32/misc.c Wed Jul 12 12:05:51 2006
@@ -16,7 +16,6 @@
 
 #include "apr_private.h"
 #include "apr_arch_misc.h"
-#include "crtdbg.h"
 #include "apr_arch_file_io.h"
 #include "assert.h"
 #include "apr_lib.h"

Modified: apr/apr/trunk/misc/win32/start.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/misc/win32/start.c?rev=421373&r1=421372&r2=421373&view=diff
==============================================================================
--- apr/apr/trunk/misc/win32/start.c (original)
+++ apr/apr/trunk/misc/win32/start.c Wed Jul 12 12:05:51 2006
@@ -23,7 +23,6 @@
 #include "apr_arch_misc.h"       /* for WSAHighByte / WSALowByte */
 #include "wchar.h"
 #include "apr_arch_file_io.h"
-#include "crtdbg.h"
 #include "assert.h"
 
 /* This symbol is _private_, although it must be exported.
@@ -54,8 +53,8 @@
     }
     wsize = 1 + wch - arrsz;
 
-    newarr = _malloc_dbg((args + 1) * sizeof(char *),
-                         _CRT_BLOCK, __FILE__, __LINE__);
+    newarr = apr_malloc_dbg((args + 1) * sizeof(char *),
+                            __FILE__, __LINE__);
 
     /* This is a safe max allocation, we will realloc after
      * processing and return the excess to the free store.
@@ -63,8 +62,8 @@
      * 4 ucs bytes will hold a wchar_t pair value (20 bits)
      */
     newlen = totlen = wsize * 3 + 1;
-    newarr[0] = _malloc_dbg(newlen * sizeof(char), 
-                            _CRT_BLOCK, __FILE__, __LINE__);
+    newarr[0] = apr_malloc_dbg(newlen * sizeof(char),
+                               __FILE__, __LINE__);
 
     (void)apr_conv_ucs2_to_utf8(arrsz, &wsize,
                                 newarr[0], &newlen);
@@ -72,8 +71,8 @@
     assert(newlen && !wsize);
     /* Return to the free store if the heap realloc is the least bit optimized
      */
-    newarr[0] = _realloc_dbg(newarr[0], totlen - newlen, 
-                             _CRT_BLOCK, __FILE__, __LINE__);
+    newarr[0] = apr_realloc_dbg(newarr[0], totlen - newlen,
+                                __FILE__, __LINE__);
 
     for (arg = 1; arg < args; ++arg) {
         newarr[arg] = newarr[arg - 1] + 2;
@@ -128,8 +127,8 @@
         dupenv = warrsztoastr(&_environ, sysstr, -1);
 
 	if (env) {
-            *env = _malloc_dbg((dupenv + 1) * sizeof (char *), 
-                               _CRT_BLOCK, __FILE__, __LINE__ );
+            *env = apr_malloc_dbg((dupenv + 1) * sizeof (char *),
+                                  __FILE__, __LINE__ );
             memcpy((void*)*env, _environ, (dupenv + 1) * sizeof (char *));
         }
         else {



Mime
View raw message