Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 85749df

Browse files
committed
Merge remote-tracking branch 'remotes/internal/release_1.0.3a'
2 parents 6248378 + c930518 commit 85749df

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

include/caffe/util/cpu_info.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class CpuInfo : public CpuInfoInterface {
8383
const char *currentLine;
8484

8585
void loadContentFromFile(const char *fileName);
86-
void loadContent(const char *content);
86+
void loadContent(std::string &content);
8787
void parseLines(char *content);
8888
};
8989

src/caffe/util/cpu_info.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ CpuInfo::CpuInfo() {
6161
}
6262

6363
CpuInfo::CpuInfo(const char *content) {
64-
loadContent(content);
64+
std::string str_content(content);
65+
loadContent(str_content);
6566
}
6667

6768
void CpuInfo::loadContentFromFile(const char *fileName) {
@@ -70,13 +71,13 @@ void CpuInfo::loadContentFromFile(const char *fileName) {
7071
(std::istreambuf_iterator<char>(file)),
7172
(std::istreambuf_iterator<char>()));
7273

73-
loadContent(content.c_str());
74+
loadContent(content);
7475
}
7576

76-
void CpuInfo::loadContent(const char *content) {
77-
size_t contentLength = strlen(content);
77+
void CpuInfo::loadContent(std::string &content) {
78+
size_t contentLength = content.length();
7879
char *contentCopy = new char[contentLength + 1];
79-
snprintf(contentCopy, contentLength + 1, "%s", content);
80+
snprintf(contentCopy, contentLength + 1, "%s", content.c_str());
8081

8182
parseLines(contentCopy);
8283

0 commit comments

Comments
 (0)