Make valgrind a bit more happy by zero-terminating/initializing strings.

Tiny cleanup on the way...

Review URL: https://codereview.chromium.org/1007283006

Cr-Commit-Position: refs/heads/master@{#27226}
This commit is contained in:
svenpanne 2015-03-16 08:34:03 -07:00 committed by Commit bot
parent dde730ff50
commit e059be3347
2 changed files with 10 additions and 13 deletions

View File

@ -27,9 +27,9 @@ namespace compiler {
FILE* OpenVisualizerLogFile(CompilationInfo* info, const char* phase,
const char* suffix, const char* mode) {
EmbeddedVector<char, 256> filename;
EmbeddedVector<char, 256> filename(0);
SmartArrayPointer<char> function_name;
if (!info->shared_info().is_null()) {
if (info->has_shared_info()) {
function_name = info->shared_info()->DebugName()->ToCString();
if (strlen(function_name.get()) > 0) {
SNPrintF(filename, "turbo-%s", function_name.get());

View File

@ -291,20 +291,17 @@ static void TraceSchedule(Schedule* schedule) {
static SmartArrayPointer<char> GetDebugName(CompilationInfo* info) {
SmartArrayPointer<char> name;
if (info->IsStub()) {
if (info->code_stub() != NULL) {
CodeStub::Major major_key = info->code_stub()->MajorKey();
const char* major_name = CodeStub::MajorName(major_key, false);
size_t len = strlen(major_name);
name.Reset(new char[len]);
memcpy(name.get(), major_name, len);
}
if (info->code_stub() != NULL) {
CodeStub::Major major_key = info->code_stub()->MajorKey();
const char* major_name = CodeStub::MajorName(major_key, false);
size_t len = strlen(major_name) + 1;
SmartArrayPointer<char> name(new char[len]);
memcpy(name.get(), major_name, len);
return name;
} else {
AllowHandleDereference allow_deref;
name = info->function()->debug_name()->ToCString();
return info->function()->debug_name()->ToCString();
}
return name;
}