]> Kevux Git Server - rit/commit
oidmap: make entry cleanup explicit in oidmap_clear
authorSeyi Kufoiji <kuforiji98@gmail.com>
Thu, 5 Mar 2026 10:05:25 +0000 (11:05 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Mar 2026 19:16:18 +0000 (11:16 -0800)
commita06a725c7847840ac56c0e797a829ac13abbe350
tree945daadd069596fe816184ddcdced52e36d8011b
parent67ad42147a7acc2af6074753ebd03d904476118f
oidmap: make entry cleanup explicit in oidmap_clear

Replace oidmap's use of hashmap_clear_() and layout-dependent freeing
with an explicit iteration and optional free callback. This removes
reliance on struct layout assumptions while keeping the existing API
intact.

Add tests for oidmap_clear_with_free behavior.
test_oidmap__clear_with_free_callback verifies that entries are freed
when a callback is provided, while
test_oidmap__clear_without_free_callback verifies that entries are not
freed when no callback is given. These tests ensure the new clear
implementation behaves correctly and preserves ownership semantics.

Signed-off-by: Seyi Kuforiji <kuforiji98@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
oidmap.c
oidmap.h
t/unit-tests/u-oidmap.c