diff options
Diffstat (limited to 'util/env_posix.cc')
-rw-r--r-- | util/env_posix.cc | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/util/env_posix.cc b/util/env_posix.cc index 4bfaf6c..e758d5f 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -282,7 +282,7 @@ class PosixWritableFile : public WritableFile { const char* sep = strrchr(f, '/'); Slice basename; std::string dir; - if (sep == NULL) { + if (sep == nullptr) { dir = "."; basename = f; } else { @@ -390,7 +390,7 @@ class PosixEnv : public Env { SequentialFile** result) { int fd = open(fname.c_str(), O_RDONLY); if (fd < 0) { - *result = NULL; + *result = nullptr; return PosixError(fname, errno); } else { *result = new PosixSequentialFile(fname, fd); @@ -400,7 +400,7 @@ class PosixEnv : public Env { virtual Status NewRandomAccessFile(const std::string& fname, RandomAccessFile** result) { - *result = NULL; + *result = nullptr; Status s; int fd = open(fname.c_str(), O_RDONLY); if (fd < 0) { @@ -409,7 +409,7 @@ class PosixEnv : public Env { uint64_t size; s = GetFileSize(fname, &size); if (s.ok()) { - void* base = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); + void* base = mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0); if (base != MAP_FAILED) { *result = new PosixMmapReadableFile(fname, base, size, &mmap_limit_); } else { @@ -431,7 +431,7 @@ class PosixEnv : public Env { Status s; int fd = open(fname.c_str(), O_TRUNC | O_WRONLY | O_CREAT, 0644); if (fd < 0) { - *result = NULL; + *result = nullptr; s = PosixError(fname, errno); } else { *result = new PosixWritableFile(fname, fd); @@ -444,7 +444,7 @@ class PosixEnv : public Env { Status s; int fd = open(fname.c_str(), O_APPEND | O_WRONLY | O_CREAT, 0644); if (fd < 0) { - *result = NULL; + *result = nullptr; s = PosixError(fname, errno); } else { *result = new PosixWritableFile(fname, fd); @@ -460,11 +460,11 @@ class PosixEnv : public Env { std::vector<std::string>* result) { result->clear(); DIR* d = opendir(dir.c_str()); - if (d == NULL) { + if (d == nullptr) { return PosixError(dir, errno); } struct dirent* entry; - while ((entry = readdir(d)) != NULL) { + while ((entry = readdir(d)) != nullptr) { result->push_back(entry->d_name); } closedir(d); @@ -516,7 +516,7 @@ class PosixEnv : public Env { } virtual Status LockFile(const std::string& fname, FileLock** lock) { - *lock = NULL; + *lock = nullptr; Status result; int fd = open(fname.c_str(), O_RDWR | O_CREAT, 0644); if (fd < 0) { @@ -576,8 +576,8 @@ class PosixEnv : public Env { virtual Status NewLogger(const std::string& fname, Logger** result) { FILE* f = fopen(fname.c_str(), "w"); - if (f == NULL) { - *result = NULL; + if (f == nullptr) { + *result = nullptr; return PosixError(fname, errno); } else { *result = new PosixLogger(f, &PosixEnv::gettid); @@ -587,7 +587,7 @@ class PosixEnv : public Env { virtual uint64_t NowMicros() { struct timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); return static_cast<uint64_t>(tv.tv_sec) * 1000000 + tv.tv_usec; } @@ -607,7 +607,7 @@ class PosixEnv : public Env { void BGThread(); static void* BGThreadWrapper(void* arg) { reinterpret_cast<PosixEnv*>(arg)->BGThread(); - return NULL; + return nullptr; } pthread_mutex_t mu_; @@ -657,8 +657,8 @@ PosixEnv::PosixEnv() : started_bgthread_(false), mmap_limit_(MaxMmaps()), fd_limit_(MaxOpenFiles()) { - PthreadCall("mutex_init", pthread_mutex_init(&mu_, NULL)); - PthreadCall("cvar_init", pthread_cond_init(&bgsignal_, NULL)); + PthreadCall("mutex_init", pthread_mutex_init(&mu_, nullptr)); + PthreadCall("cvar_init", pthread_cond_init(&bgsignal_, nullptr)); } void PosixEnv::Schedule(void (*function)(void*), void* arg) { @@ -669,7 +669,7 @@ void PosixEnv::Schedule(void (*function)(void*), void* arg) { started_bgthread_ = true; PthreadCall( "create thread", - pthread_create(&bgthread_, NULL, &PosixEnv::BGThreadWrapper, this)); + pthread_create(&bgthread_, nullptr, &PosixEnv::BGThreadWrapper, this)); } // If the queue is currently empty, the background thread may currently be @@ -713,7 +713,7 @@ static void* StartThreadWrapper(void* arg) { StartThreadState* state = reinterpret_cast<StartThreadState*>(arg); state->user_function(state->arg); delete state; - return NULL; + return nullptr; } void PosixEnv::StartThread(void (*function)(void* arg), void* arg) { @@ -722,7 +722,7 @@ void PosixEnv::StartThread(void (*function)(void* arg), void* arg) { state->user_function = function; state->arg = arg; PthreadCall("start thread", - pthread_create(&t, NULL, &StartThreadWrapper, state)); + pthread_create(&t, nullptr, &StartThreadWrapper, state)); } } // namespace @@ -732,12 +732,12 @@ static Env* default_env; static void InitDefaultEnv() { default_env = new PosixEnv; } void EnvPosixTestHelper::SetReadOnlyFDLimit(int limit) { - assert(default_env == NULL); + assert(default_env == nullptr); open_read_only_file_limit = limit; } void EnvPosixTestHelper::SetReadOnlyMMapLimit(int limit) { - assert(default_env == NULL); + assert(default_env == nullptr); mmap_limit = limit; } |