Commit 4d860005 authored by Fabrice de Gans-Riberi's avatar Fabrice de Gans-Riberi Committed by Commit Bot

Change a C-style array to an std::array

The sort function was not called with the proper arguments, missing
the last element in the array. This changes the structure to a C++
std::array and changes the arguments passed to the sort function to be
iterators rather than plain pointers.

Bug: 893369
Change-Id: I0f8cb0b991055daf1a5d39284f72681238177f1d
Tested: Locally, tests still pass.
Reviewed-on: https://chromium-review.googlesource.com/c/1287200Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarScott Graham <scottmg@chromium.org>
Commit-Queue: Fabrice de Gans-Riberi <fdegans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602041}
parent a12146cc
......@@ -16,6 +16,7 @@
#include <zircon/types.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
......@@ -69,7 +70,7 @@ class SymbolMap {
void Populate();
// Sorted in descending order by address, for lookup purposes.
Entry entries_[kMaxMapEntries];
std::array<Entry, kMaxMapEntries> entries_;
size_t count_ = 0;
bool valid_ = false;
......@@ -135,7 +136,7 @@ void SymbolMap::Populate() {
// Copy the contents of the link map linked list to |entries_|.
while (lmap != nullptr) {
if (count_ >= arraysize(entries_)) {
if (count_ >= entries_.size()) {
break;
}
SymbolMap::Entry* next_entry = &entries_[count_];
......@@ -148,7 +149,7 @@ void SymbolMap::Populate() {
}
std::sort(
&entries_[0], &entries_[count_ - 1],
entries_.begin(), entries_.begin() + count_,
[](const Entry& a, const Entry& b) -> bool { return a.addr > b.addr; });
valid_ = true;
......
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