summaryrefslogtreecommitdiff
path: root/gitweb
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2023-03-20 16:02:49 -0400
committerJunio C Hamano <gitster@pobox.com>2023-03-20 14:40:13 -0700
commit0e2a13eb16f3d2049cc26b245d374697d5f132f5 (patch)
tree9e5933deda2108ab165c3d7ad6e3c6e9c58a21a1 /gitweb
parent5abc4c1c892c1040c38522f490ca81187e7262d6 (diff)
downloadgit-0e2a13eb16f3d2049cc26b245d374697d5f132f5.tar.gz
pack-bitmap.c: factor out manual `map_pos` manipulation
The pack-bitmap internals use a combination of a `map` and `map_pos` variable to keep a pointer to a memory mapped region of the `.bitmap` file, as well as the position within that file, respectively. Reads within the memory mapped region are meant to mimic file reads, where each read adjusts the offset of the file descriptor accordingly. This functionality is implemented by adjusting the `map_pos` variable after each read. Factor out a function similar to seek() which adjusts the `map_pos` variable for us. Since the bitmap code only needs to adjust relative to the beginning of the file as well as the current position, we do not need to support any "whence" values outside of SEEK_SET and SEEK_CUR. Extracting out this operation into a separate function allows us to add some additional safety checks, such as ensuring that adding to `map_pos` does not overflow `size_t`, and that the resulting `map_pos` value is in bounds of the mapped region. The subsequent commit will rewrite all manual manipulation of the `map_pos` variable in terms of the new `bitmap_index_seek()`. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gitweb')
0 files changed, 0 insertions, 0 deletions