8230398: Remove NULL checks before FREE_C_HEAP_ARRAY jdk-14+14
authorlkorinth
Wed, 11 Sep 2019 14:16:30 +0200
changeset 58084 cddef3bde924
parent 58083 9046db64ca39
child 58086 d52f77f0acb5
8230398: Remove NULL checks before FREE_C_HEAP_ARRAY Reviewed-by: dholmes, kbarrett, tschatzl
src/hotspot/os/aix/perfMemory_aix.cpp
src/hotspot/os/bsd/perfMemory_bsd.cpp
src/hotspot/os/linux/perfMemory_linux.cpp
src/hotspot/os/solaris/os_perf_solaris.cpp
src/hotspot/os/solaris/os_solaris.cpp
src/hotspot/os/solaris/perfMemory_solaris.cpp
src/hotspot/os/windows/os_perf_windows.cpp
src/hotspot/os/windows/os_windows.cpp
src/hotspot/os/windows/perfMemory_windows.cpp
src/hotspot/share/aot/aotCodeHeap.cpp
src/hotspot/share/classfile/classLoader.cpp
src/hotspot/share/classfile/systemDictionaryShared.cpp
src/hotspot/share/code/codeBlob.cpp
src/hotspot/share/gc/cms/gSpaceCounters.cpp
src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp
src/hotspot/share/gc/g1/g1CollectionSet.cpp
src/hotspot/share/gc/g1/g1RemSetSummary.cpp
src/hotspot/share/gc/g1/heapRegionManager.cpp
src/hotspot/share/gc/g1/sparsePRT.cpp
src/hotspot/share/gc/parallel/spaceCounters.cpp
src/hotspot/share/gc/serial/cSpaceCounters.cpp
src/hotspot/share/gc/shared/cardTableRS.cpp
src/hotspot/share/gc/shared/collectorCounters.cpp
src/hotspot/share/gc/shared/generationCounters.cpp
src/hotspot/share/gc/shared/hSpaceCounters.cpp
src/hotspot/share/gc/shared/workgroup.cpp
src/hotspot/share/gc/z/zArray.inline.hpp
src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp
src/hotspot/share/jfr/support/jfrThreadLocal.cpp
src/hotspot/share/jfr/utilities/jfrHashtable.hpp
src/hotspot/share/jvmci/jvmciCodeInstaller.cpp
src/hotspot/share/memory/allocation.cpp
src/hotspot/share/memory/allocation.hpp
src/hotspot/share/oops/instanceKlass.cpp
src/hotspot/share/prims/unsafe.cpp
src/hotspot/share/runtime/arguments.cpp
src/hotspot/share/runtime/os.cpp
src/hotspot/share/runtime/os.hpp
src/hotspot/share/runtime/os_perf.hpp
src/hotspot/share/runtime/perfData.cpp
src/hotspot/share/runtime/sharedRuntime.cpp
src/hotspot/share/runtime/thread.cpp
src/hotspot/share/services/diagnosticArgument.cpp
src/hotspot/share/utilities/hashtable.cpp
--- a/src/hotspot/os/aix/perfMemory_aix.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/os/aix/perfMemory_aix.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2018 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -685,7 +685,7 @@
           if (statbuf.st_ctime > oldest_ctime) {
             char* user = strchr(dentry->d_name, '_') + 1;
 
-            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
+            FREE_C_HEAP_ARRAY(char, oldest_user);
             oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
 
             strcpy(oldest_user, user);
--- a/src/hotspot/os/bsd/perfMemory_bsd.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/os/bsd/perfMemory_bsd.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, 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
@@ -591,7 +591,7 @@
           if (statbuf.st_ctime > oldest_ctime) {
             char* user = strchr(dentry->d_name, '_') + 1;
 
-            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
+            FREE_C_HEAP_ARRAY(char, oldest_user);
             oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
 
             strcpy(oldest_user, user);
--- a/src/hotspot/os/linux/perfMemory_linux.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/os/linux/perfMemory_linux.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -629,7 +629,7 @@
           if (statbuf.st_ctime > oldest_ctime) {
             char* user = strchr(dentry->d_name, '_') + 1;
 
-            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
+            FREE_C_HEAP_ARRAY(char, oldest_user);
             oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
 
             strcpy(oldest_user, user);
--- a/src/hotspot/os/solaris/os_perf_solaris.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/os/solaris/os_perf_solaris.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -326,9 +326,7 @@
 }
 
 CPUPerformanceInterface::CPUPerformance::~CPUPerformance() {
-  if (_counters.jvmTicks != NULL) {
-    FREE_C_HEAP_ARRAY(char, _counters.jvmTicks);
-  }
+  FREE_C_HEAP_ARRAY(char, _counters.jvmTicks);
   if (_counters.kstat_ctrl != NULL) {
     kstat_close(_counters.kstat_ctrl);
   }
--- a/src/hotspot/os/solaris/os_solaris.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/os/solaris/os_solaris.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -454,9 +454,7 @@
       board = 0;
     }
   }
-  if (available_id != NULL) {
-    FREE_C_HEAP_ARRAY(bool, available_id);
-  }
+  FREE_C_HEAP_ARRAY(bool, available_id);
   return true;
 }
 
@@ -493,9 +491,7 @@
       result = false;
     }
   }
-  if (id_array != NULL) {
-    FREE_C_HEAP_ARRAY(processorid_t, id_array);
-  }
+  FREE_C_HEAP_ARRAY(processorid_t, id_array);
   return result;
 }
 
--- a/src/hotspot/os/solaris/perfMemory_solaris.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/os/solaris/perfMemory_solaris.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, 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
@@ -591,7 +591,7 @@
           if (statbuf.st_ctime > oldest_ctime) {
             char* user = strchr(dentry->d_name, '_') + 1;
 
-            if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user);
+            FREE_C_HEAP_ARRAY(char, oldest_user);
             oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
 
             strcpy(oldest_user, user);
--- a/src/hotspot/os/windows/os_perf_windows.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/os/windows/os_perf_windows.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -225,11 +225,9 @@
 }
 
 static void deallocate_counters(MultiCounterQueryP query) {
-  if (query->counters != NULL) {
-    FREE_C_HEAP_ARRAY(char, query->counters);
-    query->counters = NULL;
-    query->noOfCounters = 0;
-  }
+  FREE_C_HEAP_ARRAY(char, query->counters);
+  query->counters = NULL;
+  query->noOfCounters = 0;
 }
 
 static OSReturn add_counter(UpdateQueryP query, HCOUNTER* counter, const char* path, bool first_sample_on_init) {
@@ -659,14 +657,10 @@
 }
 
 static void deallocate_pdh_constants() {
-  if (process_image_name != NULL) {
-    FREE_C_HEAP_ARRAY(char, process_image_name);
-    process_image_name = NULL;
-  }
-  if (pdh_IDProcess_counter_fmt != NULL) {
-    FREE_C_HEAP_ARRAY(char, pdh_IDProcess_counter_fmt);
-    pdh_IDProcess_counter_fmt = NULL;
-  }
+  FREE_C_HEAP_ARRAY(char, process_image_name);
+  process_image_name = NULL;
+  FREE_C_HEAP_ARRAY(char, pdh_IDProcess_counter_fmt);
+  pdh_IDProcess_counter_fmt = NULL;
 }
 
 static int allocate_pdh_constants() {
@@ -1352,16 +1346,10 @@
 
 CPUInformationInterface::~CPUInformationInterface() {
   if (_cpu_info != NULL) {
-    const char* cpu_name = _cpu_info->cpu_name();
-    if (cpu_name != NULL) {
-      FREE_C_HEAP_ARRAY(char, cpu_name);
-      _cpu_info->set_cpu_name(NULL);
-    }
-    const char* cpu_desc = _cpu_info->cpu_description();
-    if (cpu_desc != NULL) {
-      FREE_C_HEAP_ARRAY(char, cpu_desc);
-      _cpu_info->set_cpu_description(NULL);
-    }
+    FREE_C_HEAP_ARRAY(char, _cpu_info->cpu_name());
+    _cpu_info->set_cpu_name(NULL);
+    FREE_C_HEAP_ARRAY(char, _cpu_info->cpu_description());
+    _cpu_info->set_cpu_description(NULL);
     delete _cpu_info;
     _cpu_info = NULL;
   }
--- a/src/hotspot/os/windows/os_windows.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/os/windows/os_windows.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -2727,9 +2727,7 @@
   int _numa_used_node_count;
 
   void free_node_list() {
-    if (_numa_used_node_list != NULL) {
-      FREE_C_HEAP_ARRAY(int, _numa_used_node_list);
-    }
+    FREE_C_HEAP_ARRAY(int, _numa_used_node_list);
   }
 
  public:
--- a/src/hotspot/os/windows/perfMemory_windows.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/os/windows/perfMemory_windows.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -394,7 +394,7 @@
         if (statbuf.st_ctime > latest_ctime) {
           char* user = strchr(dentry->d_name, '_') + 1;
 
-          if (latest_user != NULL) FREE_C_HEAP_ARRAY(char, latest_user);
+          FREE_C_HEAP_ARRAY(char, latest_user);
           latest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1, mtInternal);
 
           strcpy(latest_user, user);
--- a/src/hotspot/share/aot/aotCodeHeap.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/aot/aotCodeHeap.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -212,12 +212,8 @@
 }
 
 AOTCodeHeap::~AOTCodeHeap() {
-  if (_classes != NULL) {
-    FREE_C_HEAP_ARRAY(AOTClass, _classes);
-  }
-  if (_code_to_aot != NULL) {
-    FREE_C_HEAP_ARRAY(CodeToAMethod, _code_to_aot);
-  }
+  FREE_C_HEAP_ARRAY(AOTClass, _classes);
+  FREE_C_HEAP_ARRAY(CodeToAMethod, _code_to_aot);
 }
 
 AOTLib::AOTLib(void* handle, const char* name, int dso_id) : _valid(true), _dl_handle(handle), _dso_id(dso_id) {
--- a/src/hotspot/share/classfile/classLoader.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/classfile/classLoader.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -383,10 +383,8 @@
   assert(_singleton == this, "must be");
   DEBUG_ONLY(_singleton = NULL);
 
-  if (_name != NULL) {
-    FREE_C_HEAP_ARRAY(const char, _name);
-    _name = NULL;
-  }
+  FREE_C_HEAP_ARRAY(const char, _name);
+
   if (_jimage != NULL) {
     (*JImageClose)(_jimage);
     _jimage = NULL;
--- a/src/hotspot/share/classfile/systemDictionaryShared.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1059,10 +1059,8 @@
     FREE_C_HEAP_ARRAY(DTConstraint, p->_verifier_constraints);
     p->_verifier_constraints = NULL;
   }
-  if (p->_verifier_constraint_flags != NULL) {
-    FREE_C_HEAP_ARRAY(char, p->_verifier_constraint_flags);
-    p->_verifier_constraint_flags = NULL;
-  }
+  FREE_C_HEAP_ARRAY(char, p->_verifier_constraint_flags);
+  p->_verifier_constraint_flags = NULL;
   _dumptime_table->remove(k);
 }
 
--- a/src/hotspot/share/code/codeBlob.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/code/codeBlob.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -155,10 +155,8 @@
 }
 
 void CodeBlob::flush() {
-  if (_oop_maps) {
-    FREE_C_HEAP_ARRAY(unsigned char, _oop_maps);
-    _oop_maps = NULL;
-  }
+  FREE_C_HEAP_ARRAY(unsigned char, _oop_maps);
+  _oop_maps = NULL;
   _strings.free();
 }
 
--- a/src/hotspot/share/gc/cms/gSpaceCounters.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/cms/gSpaceCounters.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -74,5 +74,5 @@
 }
 
 GSpaceCounters::~GSpaceCounters() {
-  if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
+  FREE_C_HEAP_ARRAY(char, _name_space);
 }
--- a/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -72,9 +72,7 @@
   }
 
   ~EpsilonSpaceCounters() {
-    if (_name_space != NULL) {
-      FREE_C_HEAP_ARRAY(char, _name_space);
-    }
+    FREE_C_HEAP_ARRAY(char, _name_space);
   }
 
   inline void update_all(size_t capacity, size_t used) {
--- a/src/hotspot/share/gc/g1/g1CollectionSet.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectionSet.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -72,9 +72,7 @@
 }
 
 G1CollectionSet::~G1CollectionSet() {
-  if (_collection_set_regions != NULL) {
-    FREE_C_HEAP_ARRAY(uint, _collection_set_regions);
-  }
+  FREE_C_HEAP_ARRAY(uint, _collection_set_regions);
   free_optional_regions();
   clear_candidates();
 }
--- a/src/hotspot/share/gc/g1/g1RemSetSummary.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/g1/g1RemSetSummary.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -107,9 +107,7 @@
 }
 
 G1RemSetSummary::~G1RemSetSummary() {
-  if (_rs_threads_vtimes) {
-    FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes);
-  }
+  FREE_C_HEAP_ARRAY(double, _rs_threads_vtimes);
 }
 
 void G1RemSetSummary::set(G1RemSetSummary* other) {
--- a/src/hotspot/share/gc/g1/heapRegionManager.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/g1/heapRegionManager.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -531,9 +531,7 @@
 }
 
 HeapRegionClaimer::~HeapRegionClaimer() {
-  if (_claims != NULL) {
-    FREE_C_HEAP_ARRAY(uint, _claims);
-  }
+  FREE_C_HEAP_ARRAY(uint, _claims);
 }
 
 uint HeapRegionClaimer::offset_for_worker(uint worker_id) const {
--- a/src/hotspot/share/gc/g1/sparsePRT.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/g1/sparsePRT.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, 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
@@ -104,14 +104,8 @@
 }
 
 RSHashTable::~RSHashTable() {
-  if (_entries != NULL) {
-    FREE_C_HEAP_ARRAY(SparsePRTEntry, _entries);
-    _entries = NULL;
-  }
-  if (_buckets != NULL) {
-    FREE_C_HEAP_ARRAY(int, _buckets);
-    _buckets = NULL;
-  }
+  FREE_C_HEAP_ARRAY(SparsePRTEntry, _entries);
+  FREE_C_HEAP_ARRAY(int, _buckets);
 }
 
 void RSHashTable::clear() {
--- a/src/hotspot/share/gc/parallel/spaceCounters.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/parallel/spaceCounters.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -66,5 +66,5 @@
 }
 
 SpaceCounters::~SpaceCounters() {
-  if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
+  FREE_C_HEAP_ARRAY(char, _name_space);
 }
--- a/src/hotspot/share/gc/serial/cSpaceCounters.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/serial/cSpaceCounters.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -66,7 +66,7 @@
 }
 
 CSpaceCounters::~CSpaceCounters() {
-    if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
+  FREE_C_HEAP_ARRAY(char, _name_space);
 }
 
 void CSpaceCounters::update_capacity() {
--- a/src/hotspot/share/gc/shared/cardTableRS.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/shared/cardTableRS.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -624,26 +624,11 @@
 }
 
 CardTableRS::~CardTableRS() {
-  if (_last_cur_val_in_gen) {
-    FREE_C_HEAP_ARRAY(CardValue, _last_cur_val_in_gen);
-    _last_cur_val_in_gen = NULL;
-  }
-  if (_lowest_non_clean) {
-    FREE_C_HEAP_ARRAY(CardArr, _lowest_non_clean);
-    _lowest_non_clean = NULL;
-  }
-  if (_lowest_non_clean_chunk_size) {
-    FREE_C_HEAP_ARRAY(size_t, _lowest_non_clean_chunk_size);
-    _lowest_non_clean_chunk_size = NULL;
-  }
-  if (_lowest_non_clean_base_chunk_index) {
-    FREE_C_HEAP_ARRAY(uintptr_t, _lowest_non_clean_base_chunk_index);
-    _lowest_non_clean_base_chunk_index = NULL;
-  }
-  if (_last_LNC_resizing_collection) {
-    FREE_C_HEAP_ARRAY(int, _last_LNC_resizing_collection);
-    _last_LNC_resizing_collection = NULL;
-  }
+  FREE_C_HEAP_ARRAY(CardValue, _last_cur_val_in_gen);
+  FREE_C_HEAP_ARRAY(CardArr, _lowest_non_clean);
+  FREE_C_HEAP_ARRAY(size_t, _lowest_non_clean_chunk_size);
+  FREE_C_HEAP_ARRAY(uintptr_t, _lowest_non_clean_base_chunk_index);
+  FREE_C_HEAP_ARRAY(int, _last_LNC_resizing_collection);
 }
 
 void CardTableRS::initialize() {
--- a/src/hotspot/share/gc/shared/collectorCounters.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/shared/collectorCounters.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -63,9 +63,7 @@
 }
 
 CollectorCounters::~CollectorCounters() {
-  if (_name_space != NULL) {
-    FREE_C_HEAP_ARRAY(char, _name_space);
-  }
+  FREE_C_HEAP_ARRAY(char, _name_space);
 }
 
 TraceCollectorStats::TraceCollectorStats(CollectorCounters* c) :
--- a/src/hotspot/share/gc/shared/generationCounters.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/shared/generationCounters.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -80,9 +80,7 @@
 }
 
 GenerationCounters::~GenerationCounters() {
-  if (_name_space != NULL) {
-    FREE_C_HEAP_ARRAY(char, _name_space);
-  }
+  FREE_C_HEAP_ARRAY(char, _name_space);
 }
 
 void GenerationCounters::update_all() {
--- a/src/hotspot/share/gc/shared/hSpaceCounters.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/shared/hSpaceCounters.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2019, 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
@@ -67,9 +67,7 @@
 }
 
 HSpaceCounters::~HSpaceCounters() {
-  if (_name_space != NULL) {
-    FREE_C_HEAP_ARRAY(char, _name_space);
-  }
+  FREE_C_HEAP_ARRAY(char, _name_space);
 }
 
 void HSpaceCounters::update_capacity(size_t v) {
--- a/src/hotspot/share/gc/shared/workgroup.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/shared/workgroup.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -454,7 +454,7 @@
 
 
 SubTasksDone::~SubTasksDone() {
-  if (_tasks != NULL) FREE_C_HEAP_ARRAY(uint, _tasks);
+  FREE_C_HEAP_ARRAY(uint, _tasks);
 }
 
 // *** SequentialSubTasksDone
--- a/src/hotspot/share/gc/z/zArray.inline.hpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/gc/z/zArray.inline.hpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, 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
@@ -36,9 +36,7 @@
 
 template <typename T>
 inline ZArray<T>::~ZArray() {
-  if (_array != NULL) {
-    FREE_C_HEAP_ARRAY(T, _array);
-  }
+  FREE_C_HEAP_ARRAY(T, _array);
 }
 
 template <typename T>
--- a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -272,9 +272,7 @@
 }
 
 JfrStackTraceRepository::StackTrace::~StackTrace() {
-  if (_frames != NULL) {
-    FREE_C_HEAP_ARRAY(JfrStackFrame, _frames);
-  }
+  FREE_C_HEAP_ARRAY(JfrStackFrame, _frames);
 }
 
 bool JfrStackTraceRepository::StackTrace::equals(const JfrStackTrace& rhs) const {
--- a/src/hotspot/share/jfr/support/jfrThreadLocal.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/jfr/support/jfrThreadLocal.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, 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
@@ -117,9 +117,7 @@
     assert(t->is_Java_thread(), "invariant");
     JfrJavaSupport::destroy_global_jni_handle(tl->java_event_writer());
   }
-  if (tl->_stackframes != NULL) {
-    FREE_C_HEAP_ARRAY(JfrStackFrame, tl->_stackframes);
-  }
+  FREE_C_HEAP_ARRAY(JfrStackFrame, tl->_stackframes);
   tl->_dead = true;
 }
 
--- a/src/hotspot/share/jfr/utilities/jfrHashtable.hpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/jfr/utilities/jfrHashtable.hpp	Wed Sep 11 14:16:30 2019 +0200
@@ -92,10 +92,8 @@
     --_number_of_entries;
   }
   void free_buckets() {
-    if (NULL != _buckets) {
-      FREE_C_HEAP_ARRAY(Bucket, _buckets);
-      _buckets = NULL;
-    }
+    FREE_C_HEAP_ARRAY(Bucket, _buckets);
+    _buckets = NULL;
   }
   TableEntry* bucket(size_t i) { return _buckets[i].get_entry();}
   TableEntry** bucket_addr(size_t i) { return _buckets[i].entry_addr(); }
--- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -510,9 +510,7 @@
 
 #if INCLUDE_AOT
 RelocBuffer::~RelocBuffer() {
-  if (_buffer != NULL) {
-    FREE_C_HEAP_ARRAY(char, _buffer);
-  }
+  FREE_C_HEAP_ARRAY(char, _buffer);
 }
 
 address RelocBuffer::begin() const {
--- a/src/hotspot/share/memory/allocation.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/memory/allocation.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -64,6 +64,7 @@
   return p;
 }
 
+// handles NULL pointers
 void FreeHeap(void* p) {
   os::free(p);
 }
--- a/src/hotspot/share/memory/allocation.hpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/memory/allocation.hpp	Wed Sep 11 14:16:30 2019 +0200
@@ -184,6 +184,7 @@
                      MEMFLAGS flag,
                      AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
 
+// handles NULL pointers
 void FreeHeap(void* p);
 
 template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
--- a/src/hotspot/share/oops/instanceKlass.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/oops/instanceKlass.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -2546,7 +2546,7 @@
   // unreference array name derived from this class name (arrays of an unloaded
   // class can't be referenced anymore).
   if (_array_name != NULL)  _array_name->decrement_refcount();
-  if (_source_debug_extension != NULL) FREE_C_HEAP_ARRAY(char, _source_debug_extension);
+  FREE_C_HEAP_ARRAY(char, _source_debug_extension);
 }
 
 void InstanceKlass::set_source_debug_extension(const char* array, int length) {
--- a/src/hotspot/share/prims/unsafe.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/prims/unsafe.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -875,9 +875,7 @@
   }
 
   // try/finally clause:
-  if (temp_alloc != NULL) {
-    FREE_C_HEAP_ARRAY(u1, temp_alloc);
-  }
+  FREE_C_HEAP_ARRAY(u1, temp_alloc);
 
   // The anonymous class loader data has been artificially been kept alive to
   // this point.   The mirror and any instances of this class have to keep
--- a/src/hotspot/share/runtime/arguments.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/runtime/arguments.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -941,10 +941,8 @@
   (void) JVMFlag::ccstrAtPut(flag, &value, origin);
   // JVMFlag always returns a pointer that needs freeing.
   FREE_C_HEAP_ARRAY(char, value);
-  if (free_this_too != NULL) {
-    // JVMFlag made its own copy, so I must delete my own temp. buffer.
-    FREE_C_HEAP_ARRAY(char, free_this_too);
-  }
+  // JVMFlag made its own copy, so I must delete my own temp. buffer.
+  FREE_C_HEAP_ARRAY(char, free_this_too);
   return true;
 }
 
--- a/src/hotspot/share/runtime/os.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/runtime/os.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -796,7 +796,7 @@
 #endif
 }
 
-
+// handles NULL pointers
 void  os::free(void *memblock) {
   NOT_PRODUCT(inc_stat_counter(&num_frees, 1));
 #ifdef ASSERT
--- a/src/hotspot/share/runtime/os.hpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/runtime/os.hpp	Wed Sep 11 14:16:30 2019 +0200
@@ -740,6 +740,7 @@
   static void* realloc (void *memblock, size_t size, MEMFLAGS flag, const NativeCallStack& stack);
   static void* realloc (void *memblock, size_t size, MEMFLAGS flag);
 
+  // handles NULL pointers
   static void  free    (void *memblock);
   static char* strdup(const char *, MEMFLAGS flags = mtInternal);  // Like strdup
   // Like strdup, but exit VM when strdup() returns NULL
--- a/src/hotspot/share/runtime/os_perf.hpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/runtime/os_perf.hpp	Wed Sep 11 14:16:30 2019 +0200
@@ -41,12 +41,8 @@
   }
 
   ~EnvironmentVariable() {
-    if (_key != NULL) {
-      FREE_C_HEAP_ARRAY(char, _key);
-    }
-    if (_value != NULL) {
-      FREE_C_HEAP_ARRAY(char, _value);
-    }
+    FREE_C_HEAP_ARRAY(char, _key);
+    FREE_C_HEAP_ARRAY(char, _value);
   }
 
   EnvironmentVariable(char* key, char* value) {
@@ -181,15 +177,9 @@
   }
 
   virtual ~SystemProcess(void) {
-    if (_name != NULL) {
-      FREE_C_HEAP_ARRAY(char, _name);
-    }
-    if (_path != NULL) {
-      FREE_C_HEAP_ARRAY(char, _path);
-    }
-    if (_command_line != NULL) {
-      FREE_C_HEAP_ARRAY(char, _command_line);
-    }
+    FREE_C_HEAP_ARRAY(char, _name);
+    FREE_C_HEAP_ARRAY(char, _path);
+    FREE_C_HEAP_ARRAY(char, _command_line);
   }
 };
 
--- a/src/hotspot/share/runtime/perfData.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/runtime/perfData.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -113,9 +113,7 @@
 }
 
 PerfData::~PerfData() {
-  if (_name != NULL) {
-    FREE_C_HEAP_ARRAY(char, _name);
-  }
+  FREE_C_HEAP_ARRAY(char, _name);
   if (is_on_c_heap()) {
     FREE_C_HEAP_ARRAY(PerfDataEntry, _pdep);
   }
--- a/src/hotspot/share/runtime/sharedRuntime.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/runtime/sharedRuntime.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -2809,7 +2809,7 @@
 void AdapterHandlerEntry::deallocate() {
   delete _fingerprint;
 #ifdef ASSERT
-  if (_saved_code) FREE_C_HEAP_ARRAY(unsigned char, _saved_code);
+  FREE_C_HEAP_ARRAY(unsigned char, _saved_code);
 #endif
 }
 
--- a/src/hotspot/share/runtime/thread.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/runtime/thread.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -1328,10 +1328,7 @@
 {}
 
 NamedThread::~NamedThread() {
-  if (_name != NULL) {
-    FREE_C_HEAP_ARRAY(char, _name);
-    _name = NULL;
-  }
+  FREE_C_HEAP_ARRAY(char, _name);
 }
 
 void NamedThread::set_name(const char* format, ...) {
@@ -3235,7 +3232,7 @@
 
 void JavaThread::popframe_free_preserved_args() {
   assert(_popframe_preserved_args != NULL, "should not free PopFrame preserved arguments twice");
-  FREE_C_HEAP_ARRAY(char, (char*) _popframe_preserved_args);
+  FREE_C_HEAP_ARRAY(char, (char*)_popframe_preserved_args);
   _popframe_preserved_args = NULL;
   _popframe_preserved_args_size = 0;
 }
--- a/src/hotspot/share/services/diagnosticArgument.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/services/diagnosticArgument.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -36,9 +36,7 @@
 
 StringArrayArgument::~StringArrayArgument() {
   for (int i=0; i<_array->length(); i++) {
-    if(_array->at(i) != NULL) { // Safety check
-      FREE_C_HEAP_ARRAY(char, _array->at(i));
-    }
+    FREE_C_HEAP_ARRAY(char, _array->at(i));
   }
   delete _array;
 }
@@ -197,10 +195,8 @@
 }
 
 template <> void DCmdArgument<char*>::destroy_value() {
-  if (_value != NULL) {
-    FREE_C_HEAP_ARRAY(char, _value);
-    set_value(NULL);
-  }
+  FREE_C_HEAP_ARRAY(char, _value);
+  set_value(NULL);
 }
 
 template <> void DCmdArgument<NanoTimeArgument>::parse_value(const char* str,
--- a/src/hotspot/share/utilities/hashtable.cpp	Wed Sep 11 14:16:27 2019 +0200
+++ b/src/hotspot/share/utilities/hashtable.cpp	Wed Sep 11 14:16:30 2019 +0200
@@ -101,10 +101,8 @@
 }
 
 template <MEMFLAGS F> void BasicHashtable<F>::free_buckets() {
-  if (NULL != _buckets) {
-    FREE_C_HEAP_ARRAY(HashtableBucket, _buckets);
-    _buckets = NULL;
-  }
+  FREE_C_HEAP_ARRAY(HashtableBucket, _buckets);
+  _buckets = NULL;
 }
 
 // For oops and Strings the size of the literal is interesting. For other types, nobody cares.