8230398: Remove NULL checks before FREE_C_HEAP_ARRAY

Reviewed-by: dholmes, kbarrett, tschatzl
This commit is contained in:
Leo Korinth 2019-09-11 14:16:30 +02:00
parent eafb888c18
commit 4b6f9ed07f
44 changed files with 86 additions and 183 deletions

View File

@ -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 @@ 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);

View File

@ -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 @@ 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);

View File

@ -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);

View File

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

View File

@ -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;
}
@ -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;
}

View File

@ -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 @@ 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);

View File

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

View File

@ -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:

View File

@ -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);

View File

@ -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) {

View File

@ -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;

View File

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

View File

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

View File

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

View File

@ -72,9 +72,7 @@ public:
}
~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) {

View File

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

View File

@ -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) {

View File

@ -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 {

View File

@ -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(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() {

View File

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

View File

@ -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(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() {

View File

@ -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() {

View File

@ -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(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) :

View File

@ -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(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() {

View File

@ -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(const char* name_space,
}
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) {

View File

@ -454,7 +454,7 @@ void SubTasksDone::all_tasks_completed(uint n_threads) {
SubTasksDone::~SubTasksDone() {
if (_tasks != NULL) FREE_C_HEAP_ARRAY(uint, _tasks);
FREE_C_HEAP_ARRAY(uint, _tasks);
}
// *** SequentialSubTasksDone

View File

@ -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 @@ inline ZArray<T>::ZArray() :
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>

View File

@ -272,9 +272,7 @@ JfrStackTraceRepository::StackTrace::StackTrace(traceid id, const JfrStackTrace&
}
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 {

View File

@ -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 @@ void JfrThreadLocal::release(JfrThreadLocal* tl, Thread* t) {
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;
}

View File

@ -92,10 +92,8 @@ class JfrBasicHashtable : public CHeapObj<mtTracing> {
--_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(); }

View File

@ -510,9 +510,7 @@ void CodeInstaller::initialize_dependencies(JVMCIObject compiled_code, OopRecord
#if INCLUDE_AOT
RelocBuffer::~RelocBuffer() {
if (_buffer != NULL) {
FREE_C_HEAP_ARRAY(char, _buffer);
}
FREE_C_HEAP_ARRAY(char, _buffer);
}
address RelocBuffer::begin() const {

View File

@ -64,6 +64,7 @@ char* ReallocateHeap(char *old,
return p;
}
// handles NULL pointers
void FreeHeap(void* p) {
os::free(p);
}

View File

@ -184,6 +184,7 @@ char* ReallocateHeap(char *old,
MEMFLAGS flag,
AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
// handles NULL pointers
void FreeHeap(void* p);
template <MEMFLAGS F> class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {

View File

@ -2546,7 +2546,7 @@ void InstanceKlass::release_C_heap_structures() {
// 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) {

View File

@ -875,9 +875,7 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineAnonymousClass0(JNIEnv *env, jobject unsafe, j
}
// 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

View File

@ -941,10 +941,8 @@ static bool append_to_string_flag(JVMFlag* flag, const char* new_value, JVMFlag:
(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;
}

View File

@ -796,7 +796,7 @@ void* os::realloc(void *memblock, size_t size, MEMFLAGS memflags, const NativeCa
#endif
}
// handles NULL pointers
void os::free(void *memblock) {
NOT_PRODUCT(inc_stat_counter(&num_frees, 1));
#ifdef ASSERT

View File

@ -740,6 +740,7 @@ class os: AllStatic {
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

View File

@ -41,12 +41,8 @@ class EnvironmentVariable : public CHeapObj<mtInternal> {
}
~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 @@ class SystemProcess : public CHeapObj<mtInternal> {
}
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);
}
};

View File

@ -113,9 +113,7 @@ PerfData::PerfData(CounterNS ns, const char* name, Units u, Variability v)
}
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);
}

View File

@ -2809,7 +2809,7 @@ void AdapterHandlerEntry::relocate(address new_base) {
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
}

View File

@ -1328,10 +1328,7 @@ NamedThread::NamedThread() :
{}
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 @@ WordSize JavaThread::popframe_preserved_args_size_in_words() {
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;
}

View File

@ -36,9 +36,7 @@ StringArrayArgument::StringArrayArgument() {
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*>::init_value(TRAPS) {
}
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,

View File

@ -101,10 +101,8 @@ template <class T, MEMFLAGS F> HashtableEntry<T, F>* Hashtable<T, F>::allocate_n
}
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.