changeset 46298:b1aa28a58628

Merge
author ctornqvi
date Wed, 01 Mar 2017 13:24:34 +0000
parents 38f3af9e9d62 6092ca55b77b
children ebd21762a028
files
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/src/share/vm/runtime/os.cpp	Wed Mar 01 08:11:29 2017 -0500
+++ b/hotspot/src/share/vm/runtime/os.cpp	Wed Mar 01 13:24:34 2017 +0000
@@ -649,6 +649,12 @@
     return NULL;
   }
 
+  if (size == 0) {
+    // return a valid pointer if size is zero
+    // if NULL is returned the calling functions assume out of memory.
+    size = 1;
+  }
+
 #ifndef ASSERT
   NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1));
   NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size));
@@ -669,9 +675,6 @@
   // NMT support
   void* membase = MemTracker::malloc_base(memblock);
   verify_memory(membase);
-  if (size == 0) {
-    return NULL;
-  }
   // always move the block
   void* ptr = os::malloc(size, memflags, stack);
   if (PrintMalloc && tty != NULL) {