diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2024-09-09 04:51:10 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2024-09-09 04:58:52 +0000 |
| commit | 1925593a374b3e3b4cead86abc4ae352260a372e (patch) | |
| tree | 9c224ea572ad1783280d50e046896f96c27ca084 /README.md | |
| parent | readme: update mastodon link (diff) | |
render: resize(): don't overflow the number of scrollback lines
The config system allows setting the scrollback lines to
2**32-1.
However, the total number of grid lines is the scrollback lines plus
the window size, and then rounded *up* to the nearest power of two.
Furthermore, the number of rows is represented with a plain 'int'
throughout the code base.
The largest positive integer that fits in an int is 2**31-1. That
however, is not a power of two.
The largest positive integer, that also is a power of two, that fits
in an int is 2**30, or 1073741824.
Ideally, we'd just cast the line count to a 64-bit integer, and call
__builtin_clzl{,l}() on it, and then take the smallest value of that,
or 2**30. But, for some reason, __builtin_clzl(), and
__builtin_clzll() appears to ignore bits above 32, despite they being
typed to long and long long. Bug?
Instead, ensure we never call __builtin_clz() on anything larger than
2**30.
Closes #1828
Diffstat (limited to 'README.md')
0 files changed, 0 insertions, 0 deletions
