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

Side by Side Diff: src/ports/SkOSFile_posix.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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 | « src/ports/SkMemory_malloc.cpp ('k') | src/ports/SkOSFile_stdio.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkOSFile.h" 8 #include "SkOSFile.h"
9 #include "SkString.h" 9 #include "SkString.h"
10 #include "SkTFitsIn.h" 10 #include "SkTFitsIn.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 && aID.dev == bID.dev; 56 && aID.dev == bID.dev;
57 } 57 }
58 58
59 void sk_fmunmap(const void* addr, size_t length) { 59 void sk_fmunmap(const void* addr, size_t length) {
60 munmap(const_cast<void*>(addr), length); 60 munmap(const_cast<void*>(addr), length);
61 } 61 }
62 62
63 void* sk_fdmmap(int fd, size_t* size) { 63 void* sk_fdmmap(int fd, size_t* size) {
64 struct stat status; 64 struct stat status;
65 if (0 != fstat(fd, &status)) { 65 if (0 != fstat(fd, &status)) {
66 return NULL; 66 return nullptr;
67 } 67 }
68 if (!S_ISREG(status.st_mode)) { 68 if (!S_ISREG(status.st_mode)) {
69 return NULL; 69 return nullptr;
70 } 70 }
71 if (!SkTFitsIn<size_t>(status.st_size)) { 71 if (!SkTFitsIn<size_t>(status.st_size)) {
72 return NULL; 72 return nullptr;
73 } 73 }
74 size_t fileSize = static_cast<size_t>(status.st_size); 74 size_t fileSize = static_cast<size_t>(status.st_size);
75 75
76 void* addr = mmap(NULL, fileSize, PROT_READ, MAP_PRIVATE, fd, 0); 76 void* addr = mmap(nullptr, fileSize, PROT_READ, MAP_PRIVATE, fd, 0);
77 if (MAP_FAILED == addr) { 77 if (MAP_FAILED == addr) {
78 return NULL; 78 return nullptr;
79 } 79 }
80 80
81 *size = fileSize; 81 *size = fileSize;
82 return addr; 82 return addr;
83 } 83 }
84 84
85 int sk_fileno(SkFILE* f) { 85 int sk_fileno(SkFILE* f) {
86 return fileno((FILE*)f); 86 return fileno((FILE*)f);
87 } 87 }
88 88
89 void* sk_fmmap(SkFILE* f, size_t* size) { 89 void* sk_fmmap(SkFILE* f, size_t* size) {
90 int fd = sk_fileno(f); 90 int fd = sk_fileno(f);
91 if (fd < 0) { 91 if (fd < 0) {
92 return NULL; 92 return nullptr;
93 } 93 }
94 94
95 return sk_fdmmap(fd, size); 95 return sk_fdmmap(fd, size);
96 } 96 }
97 97
98 //////////////////////////////////////////////////////////////////////////// 98 ////////////////////////////////////////////////////////////////////////////
99 99
100 struct SkOSFileIterData { 100 struct SkOSFileIterData {
101 SkOSFileIterData() : fDIR(0) { } 101 SkOSFileIterData() : fDIR(0) { }
102 DIR* fDIR; 102 DIR* fDIR;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 return strLen >= suffixLen && 143 return strLen >= suffixLen &&
144 memcmp(suffix.c_str(), str + strLen - suffixLen, suffixLen) == 0; 144 memcmp(suffix.c_str(), str + strLen - suffixLen, suffixLen) == 0;
145 } 145 }
146 146
147 bool SkOSFile::Iter::next(SkString* name, bool getDir) { 147 bool SkOSFile::Iter::next(SkString* name, bool getDir) {
148 SkOSFileIterData& self = *static_cast<SkOSFileIterData*>(fSelf.get()); 148 SkOSFileIterData& self = *static_cast<SkOSFileIterData*>(fSelf.get());
149 if (self.fDIR) { 149 if (self.fDIR) {
150 dirent* entry; 150 dirent* entry;
151 151
152 while ((entry = ::readdir(self.fDIR)) != NULL) { 152 while ((entry = ::readdir(self.fDIR)) != nullptr) {
153 struct stat s; 153 struct stat s;
154 SkString str(self.fPath); 154 SkString str(self.fPath);
155 155
156 if (!str.endsWith("/") && !str.endsWith("\\")) { 156 if (!str.endsWith("/") && !str.endsWith("\\")) {
157 str.append("/"); 157 str.append("/");
158 } 158 }
159 str.append(entry->d_name); 159 str.append(entry->d_name);
160 160
161 if (0 == stat(str.c_str(), &s)) { 161 if (0 == stat(str.c_str(), &s)) {
162 if (getDir) { 162 if (getDir) {
163 if (s.st_mode & S_IFDIR) { 163 if (s.st_mode & S_IFDIR) {
164 break; 164 break;
165 } 165 }
166 } else { 166 } else {
167 if (!(s.st_mode & S_IFDIR) && issuffixfor(self.fSuffix, entr y->d_name)) { 167 if (!(s.st_mode & S_IFDIR) && issuffixfor(self.fSuffix, entr y->d_name)) {
168 break; 168 break;
169 } 169 }
170 } 170 }
171 } 171 }
172 } 172 }
173 if (entry) { // we broke out with a file 173 if (entry) { // we broke out with a file
174 if (name) { 174 if (name) {
175 name->set(entry->d_name); 175 name->set(entry->d_name);
176 } 176 }
177 return true; 177 return true;
178 } 178 }
179 } 179 }
180 return false; 180 return false;
181 } 181 }
OLDNEW
« no previous file with comments | « src/ports/SkMemory_malloc.cpp ('k') | src/ports/SkOSFile_stdio.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698