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

Side by Side Diff: compat/mac/mach-o/getsect.cc

Issue 656703002: Convert NULL to nullptr (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Fix 80-column violations Created 6 years, 2 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 | « client/simple_string_dictionary_test.cc ('k') | minidump/minidump_exception_writer.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 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 19 matching lines...) Expand all
30 #include <stddef.h> 30 #include <stddef.h>
31 31
32 #include "third_party/apple_cctools/cctools/include/mach-o/getsect.h" 32 #include "third_party/apple_cctools/cctools/include/mach-o/getsect.h"
33 33
34 namespace { 34 namespace {
35 35
36 // Returns a dlopen() handle to the same library that provides the 36 // Returns a dlopen() handle to the same library that provides the
37 // getsectbyname() function. getsectbyname() is always present in libmacho. 37 // getsectbyname() function. getsectbyname() is always present in libmacho.
38 // getsectiondata() and getsegmentdata() are not always present, but when they 38 // getsectiondata() and getsegmentdata() are not always present, but when they
39 // are, they’re in the same library as getsectbyname(). If the library cannot 39 // are, they’re in the same library as getsectbyname(). If the library cannot
40 // be found or a handle to it cannot be returned, returns NULL. 40 // be found or a handle to it cannot be returned, returns nullptr.
41 void* SystemLibMachOHandle() { 41 void* SystemLibMachOHandle() {
42 Dl_info info; 42 Dl_info info;
43 if (!dladdr(reinterpret_cast<void*>(getsectbyname), &info)) { 43 if (!dladdr(reinterpret_cast<void*>(getsectbyname), &info)) {
44 return NULL; 44 return nullptr;
45 } 45 }
46 return dlopen(info.dli_fname, RTLD_LAZY | RTLD_LOCAL); 46 return dlopen(info.dli_fname, RTLD_LAZY | RTLD_LOCAL);
47 } 47 }
48 48
49 // Returns a function pointer to a function in libmacho based on a lookup of 49 // Returns a function pointer to a function in libmacho based on a lookup of
50 // that function by symbol name. Returns NULL if libmacho cannot be found or 50 // that function by symbol name. Returns nullptr if libmacho cannot be found or
51 // opened, or if the named symbol cannot be found in libmacho. 51 // opened, or if the named symbol cannot be found in libmacho.
52 void* LookUpSystemLibMachOSymbol(const char* symbol) { 52 void* LookUpSystemLibMachOSymbol(const char* symbol) {
53 static void* dl_handle = SystemLibMachOHandle(); 53 static void* dl_handle = SystemLibMachOHandle();
54 if (!dl_handle) { 54 if (!dl_handle) {
55 return NULL; 55 return nullptr;
56 } 56 }
57 return dlsym(dl_handle, symbol); 57 return dlsym(dl_handle, symbol);
58 } 58 }
59 59
60 #ifndef __LP64__ 60 #ifndef __LP64__
61 typedef mach_header MachHeader; 61 typedef mach_header MachHeader;
62 #else 62 #else
63 typedef mach_header_64 MachHeader; 63 typedef mach_header_64 MachHeader;
64 #endif 64 #endif
65 65
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 LookUpSystemLibMachOSymbol("getsegmentdata")); 98 LookUpSystemLibMachOSymbol("getsegmentdata"));
99 if (system_getsegmentdata) { 99 if (system_getsegmentdata) {
100 return system_getsegmentdata(mhp, segname, size); 100 return system_getsegmentdata(mhp, segname, size);
101 } 101 }
102 return crashpad_getsegmentdata(mhp, segname, size); 102 return crashpad_getsegmentdata(mhp, segname, size);
103 } 103 }
104 104
105 } // extern "C" 105 } // extern "C"
106 106
107 #endif // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 107 #endif // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
OLDNEW
« no previous file with comments | « client/simple_string_dictionary_test.cc ('k') | minidump/minidump_exception_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698