Commit d4498c2a authored by Bill Budge's avatar Bill Budge

[platform] Change NULL to nullptr in platform-win32.cc.

Bug: v8:6928
Change-Id: Ie414566a8286e0ccb54447828aea660e13bafb94
Reviewed-on: https://chromium-review.googlesource.com/783632Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49587}
parent d59bf4dc
......@@ -47,14 +47,14 @@ inline void MemoryFence() {
int localtime_s(tm* out_tm, const time_t* time) {
tm* posix_local_time_struct = localtime_r(time, out_tm);
if (posix_local_time_struct == NULL) return 1;
if (posix_local_time_struct == nullptr) return 1;
return 0;
}
int fopen_s(FILE** pFile, const char* filename, const char* mode) {
*pFile = fopen(filename, mode);
return *pFile != NULL ? 0 : 1;
return *pFile != nullptr ? 0 : 1;
}
int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count,
......@@ -65,8 +65,8 @@ int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count,
int strncpy_s(char* dest, size_t dest_size, const char* source, size_t count) {
CHECK(source != NULL);
CHECK(dest != NULL);
CHECK(source != nullptr);
CHECK(dest != nullptr);
CHECK_GT(dest_size, 0);
if (count == _TRUNCATE) {
......@@ -139,11 +139,11 @@ class WindowsTimezoneCache : public TimezoneCache {
}
// Make standard and DST timezone names.
WideCharToMultiByte(CP_UTF8, 0, tzinfo_.StandardName, -1,
std_tz_name_, kTzNameSize, NULL, NULL);
WideCharToMultiByte(CP_UTF8, 0, tzinfo_.StandardName, -1, std_tz_name_,
kTzNameSize, nullptr, nullptr);
std_tz_name_[kTzNameSize - 1] = '\0';
WideCharToMultiByte(CP_UTF8, 0, tzinfo_.DaylightName, -1,
dst_tz_name_, kTzNameSize, NULL, NULL);
WideCharToMultiByte(CP_UTF8, 0, tzinfo_.DaylightName, -1, dst_tz_name_,
kTzNameSize, nullptr, nullptr);
dst_tz_name_[kTzNameSize - 1] = '\0';
// If OS returned empty string or resource id (like "@tzres.dll,-211")
......@@ -553,7 +553,7 @@ FILE* OS::FOpen(const char* path, const char* mode) {
if (fopen_s(&result, path, mode) == 0) {
return result;
} else {
return NULL;
return nullptr;
}
}
......@@ -574,13 +574,13 @@ FILE* OS::OpenTemporaryFile() {
char tempPathBuffer[MAX_PATH];
DWORD path_result = 0;
path_result = GetTempPathA(MAX_PATH, tempPathBuffer);
if (path_result > MAX_PATH || path_result == 0) return NULL;
if (path_result > MAX_PATH || path_result == 0) return nullptr;
UINT name_result = 0;
char tempNameBuffer[MAX_PATH];
name_result = GetTempFileNameA(tempPathBuffer, "", 0, tempNameBuffer);
if (name_result == 0) return NULL;
if (name_result == 0) return nullptr;
FILE* result = FOpen(tempNameBuffer, "w+"); // Same mode as tmpfile uses.
if (result != NULL) {
if (result != nullptr) {
Remove(tempNameBuffer); // Delete on close.
}
return result;
......@@ -748,7 +748,7 @@ DWORD GetProtectionFromMemoryPermission(OS::MemoryPermission access) {
uint8_t* RandomizedVirtualAlloc(size_t size, DWORD flags, DWORD protect,
void* hint) {
LPVOID base = NULL;
LPVOID base = nullptr;
static BOOL use_aslr = -1;
#ifdef V8_HOST_ARCH_32_BIT
// Don't bother randomizing on 32-bit hosts, because they lack the room and
......@@ -900,15 +900,16 @@ class Win32MemoryMappedFile final : public OS::MemoryMappedFile {
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
// Open a physical file
HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (file == INVALID_HANDLE_VALUE) return NULL;
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
OPEN_EXISTING, 0, nullptr);
if (file == INVALID_HANDLE_VALUE) return nullptr;
DWORD size = GetFileSize(file, NULL);
DWORD size = GetFileSize(file, nullptr);
// Create a file mapping for the physical file
HANDLE file_mapping =
CreateFileMapping(file, NULL, PAGE_READWRITE, 0, size, NULL);
if (file_mapping == NULL) return NULL;
CreateFileMapping(file, nullptr, PAGE_READWRITE, 0, size, nullptr);
if (file_mapping == nullptr) return nullptr;
// Map a view of the file into memory
void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
......@@ -921,13 +922,13 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name,
size_t size, void* initial) {
// Open a physical file
HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_ALWAYS, 0, NULL);
if (file == NULL) return NULL;
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
OPEN_ALWAYS, 0, nullptr);
if (file == nullptr) return nullptr;
// Create a file mapping for the physical file
HANDLE file_mapping = CreateFileMapping(file, NULL, PAGE_READWRITE, 0,
static_cast<DWORD>(size), NULL);
if (file_mapping == NULL) return NULL;
HANDLE file_mapping = CreateFileMapping(file, nullptr, PAGE_READWRITE, 0,
static_cast<DWORD>(size), nullptr);
if (file_mapping == nullptr) return nullptr;
// Map a view of the file into memory
void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
if (memory) memmove(memory, initial, size);
......@@ -1043,7 +1044,7 @@ typedef BOOL (__stdcall *DLL_FUNC_TYPE(Module32NextW))(HANDLE hSnapshot,
#undef VOID
// Declare a variable for each dynamically loaded DLL function.
#define DEF_DLL_FUNCTION(name) DLL_FUNC_TYPE(name) DLL_FUNC_VAR(name) = NULL;
#define DEF_DLL_FUNCTION(name) DLL_FUNC_TYPE(name) DLL_FUNC_VAR(name) = nullptr;
DBGHELP_FUNCTION_LIST(DEF_DLL_FUNCTION)
TLHELP32_FUNCTION_LIST(DEF_DLL_FUNCTION)
#undef DEF_DLL_FUNCTION
......@@ -1060,7 +1061,7 @@ static bool LoadDbgHelpAndTlHelp32() {
// Load functions from the dbghelp.dll module.
module = LoadLibrary(TEXT("dbghelp.dll"));
if (module == NULL) {
if (module == nullptr) {
return false;
}
......@@ -1075,7 +1076,7 @@ DBGHELP_FUNCTION_LIST(LOAD_DLL_FUNC)
// Load functions from the kernel32.dll module (the TlHelp32.h function used
// to be in tlhelp32.dll but are now moved to kernel32.dll).
module = LoadLibrary(TEXT("kernel32.dll"));
if (module == NULL) {
if (module == nullptr) {
return false;
}
......@@ -1088,14 +1089,14 @@ TLHELP32_FUNCTION_LIST(LOAD_DLL_FUNC)
#undef LOAD_DLL_FUNC
// Check that all functions where loaded.
bool result =
#define DLL_FUNC_LOADED(name) (DLL_FUNC_VAR(name) != NULL) &&
bool result =
#define DLL_FUNC_LOADED(name) (DLL_FUNC_VAR(name) != nullptr)&&
DBGHELP_FUNCTION_LIST(DLL_FUNC_LOADED)
TLHELP32_FUNCTION_LIST(DLL_FUNC_LOADED)
DBGHELP_FUNCTION_LIST(DLL_FUNC_LOADED)
TLHELP32_FUNCTION_LIST(DLL_FUNC_LOADED)
#undef DLL_FUNC_LOADED
true;
true;
dbghelp_loaded = result;
return result;
......@@ -1122,7 +1123,7 @@ static std::vector<OS::SharedLibraryAddress> LoadSymbols(
// Initialize the symbol engine.
ok = _SymInitialize(process_handle, // hProcess
NULL, // UserSearchPath
nullptr, // UserSearchPath
false); // fInvadeProcess
if (!ok) return result;
......@@ -1166,10 +1167,10 @@ static std::vector<OS::SharedLibraryAddress> LoadSymbols(
}
}
int lib_name_length = WideCharToMultiByte(
CP_UTF8, 0, module_entry.szExePath, -1, NULL, 0, NULL, NULL);
CP_UTF8, 0, module_entry.szExePath, -1, nullptr, 0, nullptr, nullptr);
std::string lib_name(lib_name_length, 0);
WideCharToMultiByte(CP_UTF8, 0, module_entry.szExePath, -1, &lib_name[0],
lib_name_length, NULL, NULL);
lib_name_length, nullptr, nullptr);
result.push_back(OS::SharedLibraryAddress(
lib_name, reinterpret_cast<uintptr_t>(module_entry.modBaseAddr),
reinterpret_cast<uintptr_t>(module_entry.modBaseAddr +
......@@ -1245,8 +1246,7 @@ class Thread::PlatformData {
// handle until it is started.
Thread::Thread(const Options& options)
: stack_size_(options.stack_size()),
start_semaphore_(NULL) {
: stack_size_(options.stack_size()), start_semaphore_(nullptr) {
data_ = new PlatformData(kNoThread);
set_name(options.name());
}
......@@ -1270,12 +1270,8 @@ Thread::~Thread() {
// initialize thread specific structures in the C runtime library.
void Thread::Start() {
data_->thread_ = reinterpret_cast<HANDLE>(
_beginthreadex(NULL,
static_cast<unsigned>(stack_size_),
ThreadEntry,
this,
0,
&data_->thread_id_));
_beginthreadex(nullptr, static_cast<unsigned>(stack_size_), ThreadEntry,
this, 0, &data_->thread_id_));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment