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

Side by Side Diff: base/linux_util.cc

Issue 11961021: base: Convert scoped_arrays to the new scoped_ptr style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert callback changes Created 7 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 "base/linux_util.h" 5 #include "base/linux_util.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <stdlib.h> 10 #include <stdlib.h>
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 struct dirent* dent; 270 struct dirent* dent;
271 while ((dent = readdir(task))) { 271 while ((dent = readdir(task))) {
272 char* endptr; 272 char* endptr;
273 const unsigned long int tid_ul = strtoul(dent->d_name, &endptr, 10); 273 const unsigned long int tid_ul = strtoul(dent->d_name, &endptr, 10);
274 if (tid_ul == ULONG_MAX || *endptr) 274 if (tid_ul == ULONG_MAX || *endptr)
275 continue; 275 continue;
276 tids.push_back(tid_ul); 276 tids.push_back(tid_ul);
277 } 277 }
278 closedir(task); 278 closedir(task);
279 279
280 scoped_array<char> syscall_data(new char[expected_data.length()]); 280 scoped_ptr<char[]> syscall_data(new char[expected_data.length()]);
281 for (std::vector<pid_t>::const_iterator 281 for (std::vector<pid_t>::const_iterator
282 i = tids.begin(); i != tids.end(); ++i) { 282 i = tids.begin(); i != tids.end(); ++i) {
283 const pid_t current_tid = *i; 283 const pid_t current_tid = *i;
284 snprintf(buf, sizeof(buf), "/proc/%d/task/%d/syscall", pid, current_tid); 284 snprintf(buf, sizeof(buf), "/proc/%d/task/%d/syscall", pid, current_tid);
285 int fd = open(buf, O_RDONLY); 285 int fd = open(buf, O_RDONLY);
286 if (fd < 0) 286 if (fd < 0)
287 continue; 287 continue;
288 if (syscall_supported != NULL) 288 if (syscall_supported != NULL)
289 *syscall_supported = true; 289 *syscall_supported = true;
290 bool read_ret = 290 bool read_ret =
291 file_util::ReadFromFD(fd, syscall_data.get(), expected_data.length()); 291 file_util::ReadFromFD(fd, syscall_data.get(), expected_data.length());
292 close(fd); 292 close(fd);
293 if (!read_ret) 293 if (!read_ret)
294 continue; 294 continue;
295 295
296 if (0 == strncmp(expected_data.c_str(), syscall_data.get(), 296 if (0 == strncmp(expected_data.c_str(), syscall_data.get(),
297 expected_data.length())) { 297 expected_data.length())) {
298 return current_tid; 298 return current_tid;
299 } 299 }
300 } 300 }
301 return -1; 301 return -1;
302 } 302 }
303 303
304 } // namespace base 304 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698