Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Unified Diff: runtime/vm/cpuinfo_linux.cc

Issue 1677043003: 1. Fix memory leaks reported by running a simple test using ASAN (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address-code-review Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/cpuinfo_android.cc ('k') | runtime/vm/cpuinfo_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/cpuinfo_linux.cc
diff --git a/runtime/vm/cpuinfo_linux.cc b/runtime/vm/cpuinfo_linux.cc
index e58bac1fe6a0d5f2f6bb953a6904038386854b8b..8d76233194a59cb0ef9416dcb362f79ffb886af6 100644
--- a/runtime/vm/cpuinfo_linux.cc
+++ b/runtime/vm/cpuinfo_linux.cc
@@ -67,7 +67,10 @@ void CpuInfo::Cleanup() {
bool CpuInfo::FieldContains(CpuInfoIndices idx, const char* search_string) {
if (method_ == kCpuInfoCpuId) {
- return strstr(CpuId::field(idx), search_string);
+ const char* field = CpuId::field(idx);
+ bool contains = (strstr(field, search_string) != NULL);
+ free(const_cast<char*>(field));
+ return contains;
} else {
ASSERT(method_ == kCpuInfoSystem);
return ProcCpuInfo::FieldContains(FieldName(idx), search_string);
@@ -75,23 +78,6 @@ bool CpuInfo::FieldContains(CpuInfoIndices idx, const char* search_string) {
}
-bool CpuInfo::FieldContainsByString(const char* field,
- const char* search_string) {
- if (method_ == kCpuInfoCpuId) {
- for (int i = 0; i < kCpuInfoMax; i++) {
- if (strcmp(field, fields_[i]) == 0) {
- return FieldContains(static_cast<CpuInfoIndices>(i), search_string);
- }
- }
- UNIMPLEMENTED();
- return false;
- } else {
- ASSERT(method_ == kCpuInfoSystem);
- return ProcCpuInfo::FieldContains(field, search_string);
- }
-}
-
-
const char* CpuInfo::ExtractField(CpuInfoIndices idx) {
if (method_ == kCpuInfoCpuId) {
return CpuId::field(idx);
@@ -102,22 +88,6 @@ const char* CpuInfo::ExtractField(CpuInfoIndices idx) {
}
-const char* CpuInfo::ExtractFieldByString(const char* field) {
- if (method_ == kCpuInfoCpuId) {
- for (int i = 0; i < kCpuInfoMax; i++) {
- if (strcmp(field, fields_[i]) == 0) {
- return ExtractField(static_cast<CpuInfoIndices>(i));
- }
- }
- UNIMPLEMENTED();
- return NULL;
- } else {
- ASSERT(method_ == kCpuInfoSystem);
- return ProcCpuInfo::ExtractField(field);
- }
-}
-
-
bool CpuInfo::HasField(const char* field) {
if (method_ == kCpuInfoCpuId) {
return (strcmp(field, fields_[kCpuInfoProcessor]) == 0) ||
« no previous file with comments | « runtime/vm/cpuinfo_android.cc ('k') | runtime/vm/cpuinfo_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698