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

Side by Side Diff: runtime/bin/directory_android.cc

Issue 16929007: - Do NOT mix malloc/free and new/delete! (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/directory.h ('k') | runtime/bin/directory_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 9
10 #include <dirent.h> // NOLINT 10 #include <dirent.h> // NOLINT
11 #include <errno.h> // NOLINT 11 #include <errno.h> // NOLINT
12 #include <string.h> // NOLINT 12 #include <string.h> // NOLINT
13 #include <sys/param.h> // NOLINT 13 #include <sys/param.h> // NOLINT
14 #include <sys/stat.h> // NOLINT 14 #include <sys/stat.h> // NOLINT
15 #include <unistd.h> // NOLINT 15 #include <unistd.h> // NOLINT
16 16
17 #include "bin/file.h" 17 #include "bin/file.h"
18 #include "bin/platform.h" 18 #include "bin/platform.h"
19 19
20 20
21 namespace dart { 21 namespace dart {
22 namespace bin { 22 namespace bin {
23 23
24 24
25 PathBuffer::PathBuffer() : length_(0) { 25 PathBuffer::PathBuffer() : length_(0) {
26 data_ = new char[PATH_MAX + 1]; 26 data_ = calloc(PATH_MAX + 1, sizeof(char)); // NOLINT
27 } 27 }
28 28
29 bool PathBuffer::AddW(const wchar_t* name) { 29 bool PathBuffer::AddW(const wchar_t* name) {
30 UNREACHABLE(); 30 UNREACHABLE();
31 return false; 31 return false;
32 } 32 }
33 33
34 char* PathBuffer::AsString() const { 34 char* PathBuffer::AsString() const {
35 return reinterpret_cast<char*>(data_); 35 return reinterpret_cast<char*>(data_);
36 } 36 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 188 }
189 189
190 if (closedir(reinterpret_cast<DIR*>(lister_)) == -1) { 190 if (closedir(reinterpret_cast<DIR*>(lister_)) == -1) {
191 return kListError; 191 return kListError;
192 } 192 }
193 193
194 return kListDone; 194 return kListDone;
195 } 195 }
196 196
197 197
198 void DirectoryListingEntry::ResetLink() {
199 if (link_ != NULL && (parent_ == NULL || parent_->link_ != link_)) {
200 delete link_;
201 link_ = NULL;
202 }
203 if (parent_ != NULL) {
204 link_ = parent_->link_;
205 }
206 }
207
208
198 static bool DeleteRecursively(PathBuffer* path); 209 static bool DeleteRecursively(PathBuffer* path);
199 210
200 211
201 static bool DeleteFile(char* file_name, 212 static bool DeleteFile(char* file_name,
202 PathBuffer* path) { 213 PathBuffer* path) {
203 return path->Add(file_name) && unlink(path->AsString()) == 0; 214 return path->Add(file_name) && unlink(path->AsString()) == 0;
204 } 215 }
205 216
206 217
207 static bool DeleteDir(char* dir_name, 218 static bool DeleteDir(char* dir_name,
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 bool Directory::Rename(const char* path, const char* new_path) { 444 bool Directory::Rename(const char* path, const char* new_path) {
434 ExistsResult exists = Exists(path); 445 ExistsResult exists = Exists(path);
435 if (exists != EXISTS) return false; 446 if (exists != EXISTS) return false;
436 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0); 447 return (TEMP_FAILURE_RETRY(rename(path, new_path)) == 0);
437 } 448 }
438 449
439 } // namespace bin 450 } // namespace bin
440 } // namespace dart 451 } // namespace dart
441 452
442 #endif // defined(TARGET_OS_ANDROID) 453 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/directory.h ('k') | runtime/bin/directory_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698