forked from The-OpenROAD-Project/OpenROAD
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use non-resizable dynamic array in
gcNet
and gcPin
Resizing these arrays could lead to dangling pointers and hard to find bugs. Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
- Loading branch information
1 parent
3a35d15
commit 6135fe3
Showing
5 changed files
with
71 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
#include <vector> | ||
|
||
template <typename T> | ||
class dynarray | ||
{ | ||
public: | ||
dynarray() = default; | ||
dynarray(std::vector<T>&& data) : data(std::move(data)) {} | ||
dynarray(size_t size) : data(size) {} | ||
T& operator[](size_t idx) { return data[idx]; } | ||
const T& operator[](size_t idx) const { return data[idx]; } | ||
auto begin() { return data.begin(); } | ||
auto begin() const { return data.begin(); } | ||
auto end() { return data.end(); } | ||
auto end() const { return data.end(); } | ||
size_t size() const { return data.size(); } | ||
void clear() { data.clear(); } | ||
T& front() { return data.front(); } | ||
const T& front() const { return data.front(); } | ||
T& back() { return data.back(); } | ||
const T& back() const { return data.back(); } | ||
|
||
private: | ||
std::vector<T> data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters