Skip to content

Commit

Permalink
Fix suprious out of memory error for alignment.
Browse files Browse the repository at this point in the history
  • Loading branch information
dillof committed Dec 30, 2024
1 parent 6c46c53 commit fa22606
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions .idea/editor.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/Range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,24 @@ Range Range::intersect(const Range &other) const {
return {new_start, new_size};
}


void Range::add_left(uint64_t amount) {
start -= amount;
size += amount;
}


void Range::align(uint64_t alignment) {
auto new_start = Int::align(start, alignment);
if (new_start > end()) {
size = 0;
}
else {
set_start(new_start);
}
}


void Range::remove_left(uint64_t amount) {
if (amount > size) {
throw Exception("out of memory");
Expand Down
2 changes: 1 addition & 1 deletion src/Range.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Range {

void add_left(uint64_t amount);
void add_right(uint64_t amount) {size += amount;}
void align(uint64_t alignment) {set_start(Int::align(start, alignment));}
void align(uint64_t alignment);
void remove_left(uint64_t amount);
void remove_right(uint64_t amount);
void set_start(uint64_t new_start);
Expand Down

0 comments on commit fa22606

Please sign in to comment.