# HG changeset patch # User coleenp # Date 1518979681 18000 # Node ID 1544557aab97b7c11ed9644d3d8ad4268aa00b5f # Parent a0e246b7403ac3ad86304d2acbc44ada5798e4e8 8198311: Avoid uses of global malloc and free Reviewed-by: kvn, kbarrett, dcubed, zgu diff -r a0e246b7403a -r 1544557aab97 src/hotspot/share/aot/aotCodeHeap.cpp --- a/src/hotspot/share/aot/aotCodeHeap.cpp Sun Feb 18 13:32:24 2018 -0500 +++ b/src/hotspot/share/aot/aotCodeHeap.cpp Sun Feb 18 13:48:01 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, 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 @@ -194,7 +194,7 @@ } AOTLib::~AOTLib() { - free((void*) _name); + os::free((void*) _name); } AOTCodeHeap::~AOTCodeHeap() { @@ -207,7 +207,7 @@ } AOTLib::AOTLib(void* handle, const char* name, int dso_id) : _valid(true), _dl_handle(handle), _dso_id(dso_id) { - _name = (const char*) strdup(name); + _name = (const char*) os::strdup(name); // Verify that VM runs with the same parameters as AOT tool. _config = (AOTConfiguration*) load_symbol("A.config"); diff -r a0e246b7403a -r 1544557aab97 src/hotspot/share/runtime/objectMonitor.cpp --- a/src/hotspot/share/runtime/objectMonitor.cpp Sun Feb 18 13:32:24 2018 -0500 +++ b/src/hotspot/share/runtime/objectMonitor.cpp Sun Feb 18 13:48:01 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, 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 @@ -2328,7 +2328,7 @@ if (SyncKnobs == NULL) SyncKnobs = ""; size_t sz = strlen(SyncKnobs); - char * knobs = (char *) malloc(sz + 2); + char * knobs = (char *) os::malloc(sz + 2, mtInternal); if (knobs == NULL) { vm_exit_out_of_memory(sz + 2, OOM_MALLOC_ERROR, "Parse SyncKnobs"); guarantee(0, "invariant"); @@ -2393,7 +2393,7 @@ ObjectMonitor::_sync_FailedSpins = NULL; } - free(knobs); + os::free(knobs); OrderAccess::fence(); InitDone = 1; }