diff src/share/vm/utilities/quickSort.cpp @ 10271:f9be75d21404

8012902: remove use of global operator new - take 2 Summary: The fix of 8010992, disable use of global operator new and new[] which caused failure on some tests. This takes two of the bugs also add ALLOW_OPERATOR_NEW_USAGE to prevent crash for third party code calling operator new of jvm on certain platforms. Reviewed-by: coleenp, dholmes, zgu Contributed-by: yumin.qi@oracle.com
author minqi
date Tue, 14 May 2013 09:41:12 -0700
parents 5a9fa2ba85f0
children e484fe2abebd
line wrap: on
line diff
--- a/src/share/vm/utilities/quickSort.cpp	Tue May 14 11:34:30 2013 +0400
+++ b/src/share/vm/utilities/quickSort.cpp	Tue May 14 09:41:12 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,8 @@
 
 #include "runtime/os.hpp"
 #include "utilities/quickSort.hpp"
+#include "memory/allocation.hpp"
+#include "memory/allocation.inline.hpp"
 #include <stdlib.h>
 
 static int test_comparator(int a, int b) {
@@ -187,8 +189,8 @@
   // test sorting random arrays
   for (int i = 0; i < 1000; i++) {
     int length = os::random() % 100;
-    int* test_array = new int[length];
-    int* expected_array = new int[length];
+    int* test_array = NEW_C_HEAP_ARRAY(int, length, mtInternal);
+    int* expected_array = NEW_C_HEAP_ARRAY(int, length, mtInternal);
     for (int j = 0; j < length; j++) {
         // Choose random values, but get a chance of getting duplicates
         test_array[j] = os::random() % (length * 2);
@@ -210,8 +212,8 @@
     sort(test_array, length, test_even_odd_comparator, true);
     assert(compare_arrays(test_array, expected_array, length), "Sorting already sorted array changed order of elements - not idempotent");
 
-    delete[] test_array;
-    delete[] expected_array;
+    FREE_C_HEAP_ARRAY(int, test_array, mtInternal);
+    FREE_C_HEAP_ARRAY(int, expected_array, mtInternal);
   }
 }