components/stdcxx/patches/085-memory.cpp.patch
author Stefan Teleman <stefan.teleman@oracle.com>
Thu, 14 Jul 2011 11:26:11 -0700
changeset 402 94ae4d75524c
permissions -rw-r--r--
7064836 stdcxx to Userland
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
402
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     1
--- stdcxx-4.2.1/src/memory.cpp	2008-04-24 17:25:19.000000000 -0700
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     2
+++ stdcxx-4.2.1/src/memory.cpp	2011-03-19 14:22:20.379428656 -0700
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     3
@@ -29,22 +29,23 @@
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     4
 
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     5
 #define _RWSTD_LIB_SRC
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     6
 
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     7
+#include <rw/_defs.h>
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     8
 #include <rw/_error.h>
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
     9
 #include <rw/_mutex.h>
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    10
 
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    11
 #include <new>
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    12
 #include <stdlib.h>
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    13
-
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    14
-#include <rw/_defs.h>
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    15
-
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    16
+#include <string.h>
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    17
 
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    18
 _RWSTD_NAMESPACE (__rw) {
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    19
 
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    20
-
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    21
 _RWSTD_EXPORT void*
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    22
 __rw_allocate (_RWSTD_SIZE_T nbytes, int /* = 0 */)
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    23
 {
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    24
-    void *ptr = 0;
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    25
+    void *ptr = 0UL;
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    26
+
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    27
+    if (0 == nbytes)
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    28
+	return ptr;
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    29
 
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    30
     _TRY {
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    31
 
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    32
@@ -65,12 +66,14 @@
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    33
     }
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    34
     _CATCH (...) {
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    35
         // prevent bad_alloc raised by the compiler
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    36
+	ptr = 0UL;
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    37
     }
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    38
 
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    39
     // fix broken ::operator new ()
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    40
-    if (0 == ptr)
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    41
+    if (0UL == ptr)
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    42
         _RW::__rw_throw (_RWSTD_ERROR_FIRST + 3 /* == bad_alloc */);
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    43
 
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    44
+    (void) memset (ptr, '\0', nbytes);
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    45
     return ptr;
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    46
 }
94ae4d75524c 7064836 stdcxx to Userland
Stefan Teleman <stefan.teleman@oracle.com>
parents:
diff changeset
    47