Skip to content

Commit

Permalink
Use |nullptr| instead of |NULL| under //courgette.
Browse files Browse the repository at this point in the history
Bug: 1080832
Change-Id: I7c01babed13186995b83d4c3a49ce6fdaf2c648e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2219582
Auto-Submit: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Will Harris <wfh@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773019}
  • Loading branch information
anforowicz authored and Commit Bot committed May 29, 2020
1 parent a97893d commit ab01986
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion courgette/assembly_program.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AssemblyProgram {
private:
static const int kLabelLowerLimit;

// Looks up a label or creates a new one. Might return NULL.
// Looks up a label or creates a new one. Might return nullptr.
Label* FindLabel(RVA rva, RVAToLabel* labels);

const ExecutableType kind_;
Expand Down
25 changes: 12 additions & 13 deletions courgette/memory_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class FileMapping {
bool valid() const;

// Returns a writable pointer to the beginning of the memory mapped file.
// If Create has not been called successfully, return value is NULL.
// If Create has not been called successfully, return value is nullptr.
void* view() const;

protected:
Expand Down Expand Up @@ -143,7 +143,7 @@ class TempMapping {

// A memory allocator class that allocates memory either from the heap or via a
// temporary file. The interface is STL inspired but the class does not throw
// STL exceptions on allocation failure. Instead it returns NULL.
// STL exceptions on allocation failure. Instead it returns nullptr.
// A file allocation will be made if either the requested memory size exceeds
// |kMaxHeapAllocationSize| or if a heap allocation fails.
// Allocating the memory as a mapping of a temporary file solves the problem
Expand Down Expand Up @@ -215,10 +215,10 @@ class MemoryAllocator {
count++;

if (count > max_size())
return NULL;
return nullptr;

size_type bytes = count * sizeof(T);
uint8_t* mem = NULL;
uint8_t* mem = nullptr;

// First see if we can do this allocation on the heap.
if (count < kMaxHeapAllocationSize &&
Expand All @@ -241,7 +241,7 @@ class MemoryAllocator {
if (!mem && base::UncheckedMalloc(bytes, reinterpret_cast<void**>(&mem))) {
mem[0] = static_cast<uint8_t>(HEAP_ALLOCATION);
}
return mem ? reinterpret_cast<pointer>(mem + sizeof(T)) : NULL;
return mem ? reinterpret_cast<pointer>(mem + sizeof(T)) : nullptr;
}

pointer allocate(size_type count, const void* hint) {
Expand Down Expand Up @@ -300,7 +300,7 @@ class MemoryAllocator {

pointer allocate(size_type count) {
if (count > max_size())
return NULL;
return nullptr;
pointer result = nullptr;
return base::UncheckedMalloc(count * sizeof(T),
reinterpret_cast<void**>(&result))
Expand Down Expand Up @@ -340,8 +340,7 @@ class NoThrowBuffer {
static const size_t kAllocationFailure = 0xffffffff;
static const size_t kStartSize = sizeof(T) > 0x100 ? 1 : 0x100 / sizeof(T);

NoThrowBuffer() : buffer_(NULL), size_(0), alloc_size_(0) {
}
NoThrowBuffer() : buffer_(nullptr), size_(0), alloc_size_(0) {}

~NoThrowBuffer() {
clear();
Expand All @@ -350,7 +349,7 @@ class NoThrowBuffer {
void clear() {
if (buffer_) {
alloc_.deallocate(buffer_, alloc_size_);
buffer_ = NULL;
buffer_ = nullptr;
size_ = 0;
alloc_size_ = 0;
}
Expand Down Expand Up @@ -450,25 +449,25 @@ class NoThrowBuffer {

const T* begin() const {
if (!size_)
return NULL;
return nullptr;
return buffer_;
}

T* begin() {
if (!size_)
return NULL;
return nullptr;
return buffer_;
}

const T* end() const {
if (!size_)
return NULL;
return nullptr;
return buffer_ + size_;
}

T* end() {
if (!size_)
return NULL;
return nullptr;
return buffer_ + size_;
}

Expand Down
2 changes: 1 addition & 1 deletion courgette/region.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace courgette {
class Region {
public:
// Default constructor: and empty region.
Region() : start_(NULL), length_(0) {}
Region() : start_(nullptr), length_(0) {}

// Usual constructor for regions given a |start| address and |length|.
Region(const void* start, size_t length)
Expand Down
2 changes: 1 addition & 1 deletion courgette/streams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Varint {
static const int kMax32 = 5;

// Parses a Varint32 encoded value from |source| and stores it in |output|,
// and returns a pointer to the following byte. Returns NULL if a valid
// and returns a pointer to the following byte. Returns nullptr if a valid
// varint value was not found before |limit|.
static const uint8_t* Parse32WithLimit(const uint8_t* source,
const uint8_t* limit,
Expand Down
10 changes: 7 additions & 3 deletions courgette/streams.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BasicBuffer {
// operations. The stream does not own the memory.
class SourceStream {
public:
SourceStream() : start_(NULL), end_(NULL), current_(NULL) {}
SourceStream() : start_(nullptr), end_(nullptr), current_(nullptr) {}

// Initializes the SourceStream to yield the bytes at |pointer|. The caller
// still owns the memory at |pointer| and should free the memory only after
Expand Down Expand Up @@ -192,7 +192,9 @@ class SourceStreamSet {
bool Init(SourceStream* source);

// Returns a pointer to one of the sub-streams.
SourceStream* stream(size_t id) { return id < count_ ? &streams_[id] : NULL; }
SourceStream* stream(size_t id) {
return id < count_ ? &streams_[id] : nullptr;
}

// Initialize |set| from |this|.
bool ReadSet(SourceStreamSet* set);
Expand Down Expand Up @@ -222,7 +224,9 @@ class SinkStreamSet {
void Init(size_t stream_index_limit);

// Returns a pointer to a substream.
SinkStream* stream(size_t id) { return id < count_ ? &streams_[id] : NULL; }
SinkStream* stream(size_t id) {
return id < count_ ? &streams_[id] : nullptr;
}

// CopyTo serializes the streams in this SinkStreamSet into a single target
// stream. The serialized format may be re-read by initializing a
Expand Down

0 comments on commit ab01986

Please sign in to comment.