diff a/src/hotspot/os/aix/perfMemory_aix.cpp b/src/hotspot/os/aix/perfMemory_aix.cpp --- a/src/hotspot/os/aix/perfMemory_aix.cpp +++ b/src/hotspot/os/aix/perfMemory_aix.cpp @@ -1,7 +1,7 @@ /* - * 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. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as @@ -683,11 +683,11 @@ if (statbuf.st_size > 0 && statbuf.st_ctime > oldest_ctime) { 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); oldest_ctime = statbuf.st_ctime; } diff a/src/hotspot/os/bsd/perfMemory_bsd.cpp b/src/hotspot/os/bsd/perfMemory_bsd.cpp --- a/src/hotspot/os/bsd/perfMemory_bsd.cpp +++ b/src/hotspot/os/bsd/perfMemory_bsd.cpp @@ -1,7 +1,7 @@ /* - * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -589,11 +589,11 @@ if (statbuf.st_size > 0 && statbuf.st_ctime > oldest_ctime) { 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); oldest_ctime = statbuf.st_ctime; } diff a/src/hotspot/os/linux/perfMemory_linux.cpp b/src/hotspot/os/linux/perfMemory_linux.cpp --- a/src/hotspot/os/linux/perfMemory_linux.cpp +++ b/src/hotspot/os/linux/perfMemory_linux.cpp @@ -627,11 +627,11 @@ if (statbuf.st_size > 0 && statbuf.st_ctime > oldest_ctime) { 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); oldest_ctime = statbuf.st_ctime; } diff a/src/hotspot/os/solaris/os_perf_solaris.cpp b/src/hotspot/os/solaris/os_perf_solaris.cpp --- a/src/hotspot/os/solaris/os_perf_solaris.cpp +++ b/src/hotspot/os/solaris/os_perf_solaris.cpp @@ -324,13 +324,11 @@ } return true; } 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); } } diff a/src/hotspot/os/solaris/os_solaris.cpp b/src/hotspot/os/solaris/os_solaris.cpp --- a/src/hotspot/os/solaris/os_solaris.cpp +++ b/src/hotspot/os/solaris/os_solaris.cpp @@ -452,13 +452,11 @@ board += 1; if (board * processors_per_board + 0 >= limit_id) { board = 0; } } - if (available_id != NULL) { - FREE_C_HEAP_ARRAY(bool, available_id); - } + FREE_C_HEAP_ARRAY(bool, available_id); return true; } void os::set_native_thread_name(const char *name) { if (Solaris::_pthread_setname_np != NULL) { @@ -491,13 +489,11 @@ result = assign_distribution(id_array, id_length, distribution, length); } else { result = false; } } - if (id_array != NULL) { - FREE_C_HEAP_ARRAY(processorid_t, id_array); - } + FREE_C_HEAP_ARRAY(processorid_t, id_array); return result; } bool os::bind_to_processor(uint processor_id) { // We assume that a processorid_t can be stored in a uint. diff a/src/hotspot/os/solaris/perfMemory_solaris.cpp b/src/hotspot/os/solaris/perfMemory_solaris.cpp --- a/src/hotspot/os/solaris/perfMemory_solaris.cpp +++ b/src/hotspot/os/solaris/perfMemory_solaris.cpp @@ -1,7 +1,7 @@ /* - * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -589,11 +589,11 @@ if (statbuf.st_size > 0 && statbuf.st_ctime > oldest_ctime) { 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); oldest_ctime = statbuf.st_ctime; } diff a/src/hotspot/os/windows/os_perf_windows.cpp b/src/hotspot/os/windows/os_perf_windows.cpp --- a/src/hotspot/os/windows/os_perf_windows.cpp +++ b/src/hotspot/os/windows/os_perf_windows.cpp @@ -223,15 +223,13 @@ assert(process_query != NULL, "invariant"); return allocate_counters(&process_query->set, nofCounters); } static void deallocate_counters(MultiCounterQueryP query) { - if (query->counters != NULL) { 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) { assert(query != NULL, "invariant"); assert(counter != NULL, "invariant"); @@ -657,18 +655,14 @@ dot_pos[0] = '\0'; return process_image_name; } 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() { assert(process_image_name == NULL, "invariant"); const char* pdh_image_name = pdh_process_image_name(); @@ -1350,20 +1344,14 @@ return true; } 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; } } diff a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -2719,13 +2719,11 @@ private: int *_numa_used_node_list; // allocated below 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: NUMANodeListHolder() { _numa_used_node_count = 0; diff a/src/hotspot/os/windows/perfMemory_windows.cpp b/src/hotspot/os/windows/perfMemory_windows.cpp --- a/src/hotspot/os/windows/perfMemory_windows.cpp +++ b/src/hotspot/os/windows/perfMemory_windows.cpp @@ -392,11 +392,11 @@ // later becomes the expected value. // 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); latest_ctime = statbuf.st_ctime; } diff a/src/hotspot/share/aot/aotCodeHeap.cpp b/src/hotspot/share/aot/aotCodeHeap.cpp --- a/src/hotspot/share/aot/aotCodeHeap.cpp +++ b/src/hotspot/share/aot/aotCodeHeap.cpp @@ -210,16 +210,12 @@ AOTLib::~AOTLib() { os::free((void*) _name); } 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) { _name = (const char*) os::strdup(name); diff a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -381,14 +381,14 @@ ClassPathImageEntry::~ClassPathImageEntry() { 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); + _name = NULL; + if (_jimage != NULL) { (*JImageClose)(_jimage); _jimage = NULL; } } diff a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -1057,14 +1057,12 @@ } } 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); } bool SystemDictionaryShared::is_jfr_event_class(InstanceKlass *k) { while (k) { diff a/src/hotspot/share/code/codeBlob.cpp b/src/hotspot/share/code/codeBlob.cpp --- a/src/hotspot/share/code/codeBlob.cpp +++ b/src/hotspot/share/code/codeBlob.cpp @@ -153,14 +153,12 @@ ) : CodeBlob(name, compiler_none, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete, frame_size, oop_maps, caller_must_gc_arguments) { cb->copy_code_and_locs_to(this); } 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(); } void CodeBlob::set_oop_maps(OopMapSet* p) { // Danger Will Robinson! This method allocates a big diff a/src/hotspot/share/gc/cms/gSpaceCounters.cpp b/src/hotspot/share/gc/cms/gSpaceCounters.cpp --- a/src/hotspot/share/gc/cms/gSpaceCounters.cpp +++ b/src/hotspot/share/gc/cms/gSpaceCounters.cpp @@ -1,7 +1,7 @@ /* - * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -72,7 +72,7 @@ _gen->capacity(), CHECK); } } GSpaceCounters::~GSpaceCounters() { - if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space); + FREE_C_HEAP_ARRAY(char, _name_space); } diff a/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp b/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp --- a/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp +++ b/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp @@ -70,13 +70,11 @@ PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, initial_capacity, CHECK); } } ~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) { _capacity->set_value(capacity); _used->set_value(used); diff a/src/hotspot/share/gc/g1/g1CollectionSet.cpp b/src/hotspot/share/gc/g1/g1CollectionSet.cpp --- a/src/hotspot/share/gc/g1/g1CollectionSet.cpp +++ b/src/hotspot/share/gc/g1/g1CollectionSet.cpp @@ -70,13 +70,11 @@ _inc_predicted_elapsed_time_ms(0.0), _inc_predicted_elapsed_time_ms_diff(0.0) { } 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(); } void G1CollectionSet::init_region_lengths(uint eden_cset_region_length, diff a/src/hotspot/share/gc/g1/g1RemSetSummary.cpp b/src/hotspot/share/gc/g1/g1RemSetSummary.cpp --- a/src/hotspot/share/gc/g1/g1RemSetSummary.cpp +++ b/src/hotspot/share/gc/g1/g1RemSetSummary.cpp @@ -105,13 +105,11 @@ _sampling_thread_vtime(0.0f) { update(); } 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) { assert(other != NULL, "just checking"); assert(_num_vtimes == other->_num_vtimes, "just checking"); diff a/src/hotspot/share/gc/g1/heapRegionManager.cpp b/src/hotspot/share/gc/g1/heapRegionManager.cpp --- a/src/hotspot/share/gc/g1/heapRegionManager.cpp +++ b/src/hotspot/share/gc/g1/heapRegionManager.cpp @@ -529,13 +529,11 @@ memset(new_claims, Unclaimed, sizeof(*_claims) * _n_regions); _claims = new_claims; } 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 { assert(worker_id < _n_workers, "Invalid worker_id."); return _n_regions * worker_id / _n_workers; diff a/src/hotspot/share/gc/g1/sparsePRT.cpp b/src/hotspot/share/gc/g1/sparsePRT.cpp --- a/src/hotspot/share/gc/g1/sparsePRT.cpp +++ b/src/hotspot/share/gc/g1/sparsePRT.cpp @@ -1,7 +1,7 @@ /* - * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -102,18 +102,14 @@ _entries = (SparsePRTEntry*)NEW_C_HEAP_ARRAY(char, _num_entries * SparsePRTEntry::size(), mtGC); clear(); } 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); + _entries = NULL; + FREE_C_HEAP_ARRAY(int, _buckets); + _buckets = NULL; } void RSHashTable::clear() { _occupied_entries = 0; _occupied_cards = 0; diff a/src/hotspot/share/gc/parallel/spaceCounters.cpp b/src/hotspot/share/gc/parallel/spaceCounters.cpp --- a/src/hotspot/share/gc/parallel/spaceCounters.cpp +++ b/src/hotspot/share/gc/parallel/spaceCounters.cpp @@ -1,7 +1,7 @@ /* - * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -64,7 +64,7 @@ _object_space->capacity_in_bytes(), CHECK); } } SpaceCounters::~SpaceCounters() { - if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space); + FREE_C_HEAP_ARRAY(char, _name_space); } diff a/src/hotspot/share/gc/serial/cSpaceCounters.cpp b/src/hotspot/share/gc/serial/cSpaceCounters.cpp --- a/src/hotspot/share/gc/serial/cSpaceCounters.cpp +++ b/src/hotspot/share/gc/serial/cSpaceCounters.cpp @@ -1,7 +1,7 @@ /* - * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -64,11 +64,11 @@ _space->capacity(), CHECK); } } CSpaceCounters::~CSpaceCounters() { - if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space); + FREE_C_HEAP_ARRAY(char, _name_space); } void CSpaceCounters::update_capacity() { _capacity->set_value(_space->capacity()); } diff a/src/hotspot/share/gc/shared/cardTableRS.cpp b/src/hotspot/share/gc/shared/cardTableRS.cpp --- a/src/hotspot/share/gc/shared/cardTableRS.cpp +++ b/src/hotspot/share/gc/shared/cardTableRS.cpp @@ -622,30 +622,20 @@ _last_cur_val_in_gen[i] = clean_card_val(); } } 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); + _last_cur_val_in_gen = NULL; + FREE_C_HEAP_ARRAY(CardArr, _lowest_non_clean); + _lowest_non_clean = NULL; + FREE_C_HEAP_ARRAY(size_t, _lowest_non_clean_chunk_size); + _lowest_non_clean_chunk_size = NULL; + FREE_C_HEAP_ARRAY(uintptr_t, _lowest_non_clean_base_chunk_index); + _lowest_non_clean_base_chunk_index = NULL; + FREE_C_HEAP_ARRAY(int, _last_LNC_resizing_collection); + _last_LNC_resizing_collection = NULL; } void CardTableRS::initialize() { CardTable::initialize(); _lowest_non_clean = diff a/src/hotspot/share/gc/shared/collectorCounters.cpp b/src/hotspot/share/gc/shared/collectorCounters.cpp --- a/src/hotspot/share/gc/shared/collectorCounters.cpp +++ b/src/hotspot/share/gc/shared/collectorCounters.cpp @@ -1,7 +1,7 @@ /* - * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -61,13 +61,11 @@ CHECK); } } CollectorCounters::~CollectorCounters() { - if (_name_space != NULL) { - FREE_C_HEAP_ARRAY(char, _name_space); - } + FREE_C_HEAP_ARRAY(char, _name_space); } TraceCollectorStats::TraceCollectorStats(CollectorCounters* c) : PerfTraceTimedEvent(c->time_counter(), c->invocation_counter()), _c(c) { diff a/src/hotspot/share/gc/shared/generationCounters.cpp b/src/hotspot/share/gc/shared/generationCounters.cpp --- a/src/hotspot/share/gc/shared/generationCounters.cpp +++ b/src/hotspot/share/gc/shared/generationCounters.cpp @@ -1,7 +1,7 @@ /* - * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -78,13 +78,11 @@ : _virtual_space(NULL) { initialize(name, ordinal, spaces, min_capacity, max_capacity, curr_capacity); } GenerationCounters::~GenerationCounters() { - if (_name_space != NULL) { - FREE_C_HEAP_ARRAY(char, _name_space); - } + FREE_C_HEAP_ARRAY(char, _name_space); } void GenerationCounters::update_all() { assert(_virtual_space != NULL, "otherwise, override this method"); _current_size->set_value(_virtual_space->committed_size()); diff a/src/hotspot/share/gc/shared/hSpaceCounters.cpp b/src/hotspot/share/gc/shared/hSpaceCounters.cpp --- a/src/hotspot/share/gc/shared/hSpaceCounters.cpp +++ b/src/hotspot/share/gc/shared/hSpaceCounters.cpp @@ -1,7 +1,7 @@ /* - * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -65,13 +65,11 @@ initial_capacity, CHECK); } } 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) { _capacity->set_value(v); } diff a/src/hotspot/share/gc/shared/workgroup.cpp b/src/hotspot/share/gc/shared/workgroup.cpp --- a/src/hotspot/share/gc/shared/workgroup.cpp +++ b/src/hotspot/share/gc/shared/workgroup.cpp @@ -452,11 +452,11 @@ } } SubTasksDone::~SubTasksDone() { - if (_tasks != NULL) FREE_C_HEAP_ARRAY(uint, _tasks); + FREE_C_HEAP_ARRAY(uint, _tasks); } // *** SequentialSubTasksDone void SequentialSubTasksDone::clear() { diff a/src/hotspot/share/gc/z/zArray.inline.hpp b/src/hotspot/share/gc/z/zArray.inline.hpp --- a/src/hotspot/share/gc/z/zArray.inline.hpp +++ b/src/hotspot/share/gc/z/zArray.inline.hpp @@ -1,7 +1,7 @@ /* - * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -34,13 +34,11 @@ _size(0), _capacity(0) {} template inline ZArray::~ZArray() { - if (_array != NULL) { - FREE_C_HEAP_ARRAY(T, _array); - } + FREE_C_HEAP_ARRAY(T, _array); } template inline size_t ZArray::size() const { return _size; diff a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp --- a/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp +++ b/src/hotspot/share/jfr/recorder/stacktrace/jfrStackTraceRepository.cpp @@ -270,13 +270,11 @@ memcpy(_frames, trace._frames, _nr_of_frames * sizeof(JfrStackFrame)); } } 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 { if (_reached_root != rhs._reached_root || _nr_of_frames != rhs._nr_of_frames || _hash != rhs._hash) { return false; diff a/src/hotspot/share/jfr/support/jfrThreadLocal.cpp b/src/hotspot/share/jfr/support/jfrThreadLocal.cpp --- a/src/hotspot/share/jfr/support/jfrThreadLocal.cpp +++ b/src/hotspot/share/jfr/support/jfrThreadLocal.cpp @@ -1,7 +1,7 @@ /* - * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. @@ -115,13 +115,11 @@ } if (tl->has_java_event_writer()) { 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; } void JfrThreadLocal::on_exit(Thread* t) { assert(t != NULL, "invariant"); diff a/src/hotspot/share/jfr/utilities/jfrHashtable.hpp b/src/hotspot/share/jfr/utilities/jfrHashtable.hpp --- a/src/hotspot/share/jfr/utilities/jfrHashtable.hpp +++ b/src/hotspot/share/jfr/utilities/jfrHashtable.hpp @@ -90,14 +90,12 @@ void unlink_entry(TableEntry* entry) { entry->set_next(NULL); --_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(); } uintptr_t table_size() const { return _table_size; } size_t number_of_entries() const { return _number_of_entries; } diff a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp @@ -508,13 +508,11 @@ } } #if INCLUDE_AOT RelocBuffer::~RelocBuffer() { - if (_buffer != NULL) { - FREE_C_HEAP_ARRAY(char, _buffer); - } + FREE_C_HEAP_ARRAY(char, _buffer); } address RelocBuffer::begin() const { if (_buffer != NULL) { return (address) _buffer; diff a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -2544,11 +2544,11 @@ // Decrement symbol reference counts associated with the unloaded class. if (_name != NULL) _name->decrement_refcount(); // 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) { if (array == NULL) { _source_debug_extension = NULL; diff a/src/hotspot/share/prims/unsafe.cpp b/src/hotspot/share/prims/unsafe.cpp --- a/src/hotspot/share/prims/unsafe.cpp +++ b/src/hotspot/share/prims/unsafe.cpp @@ -873,13 +873,11 @@ if (anon_klass != NULL) { res_jh = JNIHandles::make_local(env, anon_klass->java_mirror()); } // 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 // it alive afterwards. if (anon_klass != NULL) { diff a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -946,14 +946,12 @@ free_this_too = buf; } (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; } const char* Arguments::handle_aliases_and_deprecation(const char* arg, bool warn) { const char* real_name = real_flag_name(arg); diff a/src/hotspot/share/runtime/os_perf.hpp b/src/hotspot/share/runtime/os_perf.hpp --- a/src/hotspot/share/runtime/os_perf.hpp +++ b/src/hotspot/share/runtime/os_perf.hpp @@ -39,16 +39,12 @@ _key = NULL; _value = NULL; } ~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) { _key = key; _value = value; @@ -179,19 +175,13 @@ void set_command_line(char* command_line) { _command_line = command_line; } 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); } }; class NetworkInterface : public ResourceObj { private: diff a/src/hotspot/share/runtime/perfData.cpp b/src/hotspot/share/runtime/perfData.cpp --- a/src/hotspot/share/runtime/perfData.cpp +++ b/src/hotspot/share/runtime/perfData.cpp @@ -111,13 +111,11 @@ } } } 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); } } diff a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -2807,11 +2807,11 @@ 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 } #ifdef ASSERT diff a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp --- a/src/hotspot/share/runtime/thread.cpp +++ b/src/hotspot/share/runtime/thread.cpp @@ -1326,14 +1326,12 @@ _processed_thread(NULL), _gc_id(GCId::undefined()) {} NamedThread::~NamedThread() { - if (_name != NULL) { - FREE_C_HEAP_ARRAY(char, _name); - _name = NULL; - } + FREE_C_HEAP_ARRAY(char, _name); + _name = NULL; } void NamedThread::set_name(const char* format, ...) { guarantee(_name == NULL, "Only get to set name once."); _name = NEW_C_HEAP_ARRAY(char, max_name_len, mtThread); @@ -3233,11 +3231,11 @@ return in_WordSize(sz / wordSize); } 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; } #ifndef PRODUCT diff a/src/hotspot/share/services/diagnosticArgument.cpp b/src/hotspot/share/services/diagnosticArgument.cpp --- a/src/hotspot/share/services/diagnosticArgument.cpp +++ b/src/hotspot/share/services/diagnosticArgument.cpp @@ -34,13 +34,11 @@ assert(_array != NULL, "Sanity check"); } 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; } void StringArrayArgument::add(const char* str, size_t len) { @@ -195,14 +193,12 @@ set_value(NULL); } } template <> void DCmdArgument::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::parse_value(const char* str, size_t len, TRAPS) { if (str == NULL) { diff a/src/hotspot/share/utilities/hashtable.cpp b/src/hotspot/share/utilities/hashtable.cpp --- a/src/hotspot/share/utilities/hashtable.cpp +++ b/src/hotspot/share/utilities/hashtable.cpp @@ -99,14 +99,12 @@ entry->set_next(NULL); return entry; } template void BasicHashtable::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. static int literal_size(ConstantPool*) { return 0; } static int literal_size(Klass*) { return 0; }