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

Commit

Permalink
Merge remote-tracking branch 'remotes/internal/release_1.0.3a'
Browse files Browse the repository at this point in the history
  • Loading branch information
daisyden committed Sep 11, 2017
2 parents 6248378 + c930518 commit 85749df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/caffe/util/cpu_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CpuInfo : public CpuInfoInterface {
const char *currentLine;

void loadContentFromFile(const char *fileName);
void loadContent(const char *content);
void loadContent(std::string &content);
void parseLines(char *content);
};

Expand Down
11 changes: 6 additions & 5 deletions src/caffe/util/cpu_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ CpuInfo::CpuInfo() {
}

CpuInfo::CpuInfo(const char *content) {
loadContent(content);
std::string str_content(content);
loadContent(str_content);
}

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

loadContent(content.c_str());
loadContent(content);
}

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

parseLines(contentCopy);

Expand Down

0 comments on commit 85749df

Please sign in to comment.