Skip to content

Consolidate CallbackVector cleanup into free_cbv()#288

Draft
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/consolidate-free-cbv
Draft

Consolidate CallbackVector cleanup into free_cbv()#288
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/consolidate-free-cbv

Conversation

@toddr-bot

@toddr-bot toddr-bot commented May 22, 2026

Copy link
Copy Markdown
Collaborator

What

Single-owner teardown: free_cbv() now handles all CallbackVector fields, and XML_ParserFree delegates to it instead of duplicating the cleanup inline.

Why

Adding a new SV field to CallbackVector previously required updating two independent cleanup sites — free_cbv() (for early-abort in ParserCreate) and the inline block in XML_ParserFree (for normal teardown). Missing either one leaks memory. This consolidation makes the struct self-cleaning through one function.

How

  • Expanded free_cbv() with null-guarded SvREFCNT_dec for every SV handler field (recstring, start_sv through endcd_sv).
  • Added a null guard on self_sv so the function is safe for both paths: early-abort (self_sv set) and normal teardown (self_sv already NULL from XML_ParserRelease).
  • Replaced the ~70-line inline cleanup block in XML_ParserFree with free_cbv(cbv).
  • The six early-abort calls in XML_ParserCreate are unaffected — Newxz zeroes all SV fields, and SvREFCNT_dec(NULL)/Safefree(NULL) are safe no-ops.

Testing

Full test suite passes (make test — all tests OK).

🤖 Generated with Claude Code


Quality Report

Changes: 1 file changed, 64 insertions(+), 68 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Expand free_cbv() to release all SV handler fields (with null guards)
and replace the duplicated inline cleanup in XML_ParserFree with a
single call to free_cbv(). This eliminates a maintenance trap where
adding a new SV field to CallbackVector required updating two
independent cleanup sites.

The self_sv null guard ensures correctness for both paths:
- Early-abort in XML_ParserCreate (self_sv is set, freed by free_cbv)
- Normal teardown via XML_ParserFree (self_sv already NULL from Release)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.06%. Comparing base (ab2416c) to head (5b288c3).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #288      +/-   ##
==========================================
+ Coverage   76.40%   77.06%   +0.66%     
==========================================
  Files           1        1              
  Lines        1102     1112      +10     
  Branches      346      352       +6     
==========================================
+ Hits          842      857      +15     
+ Misses         52       45       -7     
- Partials      208      210       +2     
Flag Coverage Δ
perl 77.06% <100.00%> (+0.66%) ⬆️
xs 77.06% <100.00%> (+0.66%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a28ad1...5b288c3. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant