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

Side by Side Diff: src/base/file-utils.cc

Issue 2061163003: include stdlib.h when using calloc (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/base/file-utils.h" 5 #include "src/base/file-utils.h"
6 6
7 #include <stdlib.h>
7 #include <string.h> 8 #include <string.h>
8 9
9 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
10 11
11 namespace v8 { 12 namespace v8 {
12 namespace internal { 13 namespace internal {
13 14
14 char* RelativePath(char** buffer, const char* exec_path, const char* name) { 15 char* RelativePath(char** buffer, const char* exec_path, const char* name) {
15 DCHECK(exec_path); 16 DCHECK(exec_path);
16 int path_separator = static_cast<int>(strlen(exec_path)) - 1; 17 int path_separator = static_cast<int>(strlen(exec_path)) - 1;
17 while (path_separator >= 0 && 18 while (path_separator >= 0 &&
18 !base::OS::isDirectorySeparator(exec_path[path_separator])) { 19 !base::OS::isDirectorySeparator(exec_path[path_separator])) {
19 path_separator--; 20 path_separator--;
20 } 21 }
21 if (path_separator >= 0) { 22 if (path_separator >= 0) {
22 int name_length = static_cast<int>(strlen(name)); 23 int name_length = static_cast<int>(strlen(name));
23 *buffer = 24 *buffer =
24 reinterpret_cast<char*>(calloc(path_separator + name_length + 2, 1)); 25 reinterpret_cast<char*>(calloc(path_separator + name_length + 2, 1));
25 *buffer[0] = '\0'; 26 *buffer[0] = '\0';
26 strncat(*buffer, exec_path, path_separator + 1); 27 strncat(*buffer, exec_path, path_separator + 1);
27 strncat(*buffer, name, name_length); 28 strncat(*buffer, name, name_length);
28 } else { 29 } else {
29 *buffer = strdup(name); 30 *buffer = strdup(name);
30 } 31 }
31 return *buffer; 32 return *buffer;
32 } 33 }
33 34
34 } // namespace internal 35 } // namespace internal
35 } // namespace v8 36 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698