Skip to content

Commit

Permalink
Better estimate memsize of RE2::MatchData
Browse files Browse the repository at this point in the history
As `matches` is only a pointer to the first StringPiece match, ensure we
multiply it by the number of matches to get a better estimate of the
size of the `RE2::MatchData` object.
  • Loading branch information
mudge committed Nov 11, 2023
1 parent 337a1f1 commit 677352d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ext/re2/re2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static size_t re2_matchdata_memsize(const void *data) {
const re2_matchdata *self = (const re2_matchdata *)data;
size_t size = sizeof(re2_matchdata);
if (self->matches) {
size += sizeof(self->matches);
size += sizeof(self->matches) * self->number_of_matches;
}

return size;
Expand Down

0 comments on commit 677352d

Please sign in to comment.