Skip to content

Commit

Permalink
8230398: Remove NULL checks before FREE_C_HEAP_ARRAY
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, kbarrett, tschatzl
  • Loading branch information
lkorinth committed Sep 11, 2019
1 parent eafb888 commit 4b6f9ed
Show file tree
Hide file tree
Showing 44 changed files with 86 additions and 183 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/os/aix/perfMemory_aix.cpp
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -685,7 +685,7 @@ static char* get_user_name_slow(int vmid, TRAPS) {
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);
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/os/bsd/perfMemory_bsd.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -591,7 +591,7 @@ static char* get_user_name_slow(int vmid, TRAPS) {
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);
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/linux/perfMemory_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ static char* get_user_name_slow(int vmid, int nspid, TRAPS) {
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);
Expand Down
4 changes: 1 addition & 3 deletions src/hotspot/os/solaris/os_perf_solaris.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,7 @@ bool CPUPerformanceInterface::CPUPerformance::initialize() {
}

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);
}
Expand Down
8 changes: 2 additions & 6 deletions src/hotspot/os/solaris/os_solaris.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,7 @@ static bool assign_distribution(processorid_t* id_array,
board = 0;
}
}
if (available_id != NULL) {
FREE_C_HEAP_ARRAY(bool, available_id);
}
FREE_C_HEAP_ARRAY(bool, available_id);
return true;
}

Expand Down Expand Up @@ -493,9 +491,7 @@ bool os::distribute_processes(uint length, uint* distribution) {
result = false;
}
}
if (id_array != NULL) {
FREE_C_HEAP_ARRAY(processorid_t, id_array);
}
FREE_C_HEAP_ARRAY(processorid_t, id_array);
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/os/solaris/perfMemory_solaris.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -591,7 +591,7 @@ static char* get_user_name_slow(int vmid, TRAPS) {
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);
Expand Down
34 changes: 11 additions & 23 deletions src/hotspot/os/windows/os_perf_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,9 @@ static int allocate_counters(ProcessQueryP process_query, size_t nofCounters) {
}

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) {
Expand Down Expand Up @@ -659,14 +657,10 @@ static const char* pdh_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() {
Expand Down Expand Up @@ -1352,16 +1346,10 @@ bool CPUInformationInterface::initialize() {

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;
}
Expand Down
4 changes: 1 addition & 3 deletions src/hotspot/os/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2727,9 +2727,7 @@ class NUMANodeListHolder {
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:
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/os/windows/perfMemory_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ static char* get_user_name_slow(int vmid) {
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);
Expand Down
8 changes: 2 additions & 6 deletions src/hotspot/share/aot/aotCodeHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,8 @@ AOTLib::~AOTLib() {
}

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) {
Expand Down
6 changes: 2 additions & 4 deletions src/hotspot/share/classfile/classLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,8 @@ 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);

if (_jimage != NULL) {
(*JImageClose)(_jimage);
_jimage = NULL;
Expand Down
6 changes: 2 additions & 4 deletions src/hotspot/share/classfile/systemDictionaryShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,10 +1059,8 @@ void SystemDictionaryShared::remove_dumptime_info(InstanceKlass* k) {
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);
}

Expand Down
6 changes: 2 additions & 4 deletions src/hotspot/share/code/codeBlob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,8 @@ RuntimeBlob::RuntimeBlob(
}

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();
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/cms/gSpaceCounters.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -74,5 +74,5 @@ GSpaceCounters::GSpaceCounters(const char* name, int ordinal, size_t max_size,
}

GSpaceCounters::~GSpaceCounters() {
if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
FREE_C_HEAP_ARRAY(char, _name_space);
}
4 changes: 1 addition & 3 deletions src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ class EpsilonSpaceCounters: public CHeapObj<mtGC> {
}

~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) {
Expand Down
4 changes: 1 addition & 3 deletions src/hotspot/share/gc/g1/g1CollectionSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy) :
}

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();
}
Expand Down
4 changes: 1 addition & 3 deletions src/hotspot/share/gc/g1/g1RemSetSummary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ G1RemSetSummary::G1RemSetSummary(G1RemSet* rem_set) :
}

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) {
Expand Down
4 changes: 1 addition & 3 deletions src/hotspot/share/gc/g1/heapRegionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,7 @@ HeapRegionClaimer::HeapRegionClaimer(uint n_workers) :
}

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 {
Expand Down
12 changes: 3 additions & 9 deletions src/hotspot/share/gc/g1/sparsePRT.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -104,14 +104,8 @@ RSHashTable::RSHashTable(size_t capacity) :
}

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() {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/parallel/spaceCounters.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -66,5 +66,5 @@ SpaceCounters::SpaceCounters(const char* name, int ordinal, size_t max_size,
}

SpaceCounters::~SpaceCounters() {
if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
FREE_C_HEAP_ARRAY(char, _name_space);
}
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/serial/cSpaceCounters.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -66,7 +66,7 @@ CSpaceCounters::CSpaceCounters(const char* name, int ordinal, size_t max_size,
}

CSpaceCounters::~CSpaceCounters() {
if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
FREE_C_HEAP_ARRAY(char, _name_space);
}

void CSpaceCounters::update_capacity() {
Expand Down
25 changes: 5 additions & 20 deletions src/hotspot/share/gc/shared/cardTableRS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,26 +624,11 @@ CardTableRS::CardTableRS(MemRegion whole_heap, bool scanned_concurrently) :
}

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() {
Expand Down
6 changes: 2 additions & 4 deletions src/hotspot/share/gc/shared/collectorCounters.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -63,9 +63,7 @@ CollectorCounters::CollectorCounters(const char* name, int ordinal) {
}

CollectorCounters::~CollectorCounters() {
if (_name_space != NULL) {
FREE_C_HEAP_ARRAY(char, _name_space);
}
FREE_C_HEAP_ARRAY(char, _name_space);
}

TraceCollectorStats::TraceCollectorStats(CollectorCounters* c) :
Expand Down
6 changes: 2 additions & 4 deletions src/hotspot/share/gc/shared/generationCounters.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -80,9 +80,7 @@ GenerationCounters::GenerationCounters(const char* name,
}

GenerationCounters::~GenerationCounters() {
if (_name_space != NULL) {
FREE_C_HEAP_ARRAY(char, _name_space);
}
FREE_C_HEAP_ARRAY(char, _name_space);
}

void GenerationCounters::update_all() {
Expand Down
Loading

0 comments on commit 4b6f9ed

Please sign in to comment.