Skip to content

Conversation

@ayushman1210
Copy link
Contributor

@ayushman1210 ayushman1210 commented Jan 17, 2026

  1. Added function declaration in context.h
  • Added destroyContextMetadata() function declaration with documentation explaining its purpose
  1. Implemented cleanup function in context.c
    Created destroyContextMetadata() that
  • Iterates through the ctx.metaMap hash table using HASH_ITER macro
  • Safely deletes each entry using HASH_DEL
  • Frees the allocated memory for each metadata structure
  • Sets ctx.metaMap to NULL after cleanup
  1. Integrated cleanup into sipnet.c
    Added call to destroyContextMetadata() at the end of cleanupModel() function

Implementation Details
The implementation uses the uthash library's HASH_ITER and HASH_DEL macros for safe iteration and deletion:

  • HASH_ITER safely iterates through the hash table while allowing deletion of elements
  • HASH_DEL removes each element from the hash table
  • free() deallocates the memory for each context_metadata structure
  • Setting ctx.metaMap = NULL prevents potential use-after-free issues

Fixes

#211

Copy link
Member

@dlebauer dlebauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ayushman1210 thank you for reporting this bug and submitting these changes.

Unfortunately, it looks like these changes. Include your updates to documentation, maybe the same as are in #203.

Could you please either take those files out of this PR or submit a new one so that the PR is focused on the related issue? Either approach would be fine.

And as a minor request, for future reference - it is helpful if you can prepend the branch name and pr title with the feature number.

@ayushman1210
Copy link
Contributor Author

Hi @dlebauer sorry for the late response
I have updated the branch so the PR now contains only the context metadata cleanup commit (f6550f9), rebased cleanly on upstream/master.
please review this pr when you have some free time
thanks !!

@ayushman1210 ayushman1210 requested a review from dlebauer January 19, 2026 20:49
@dlebauer
Copy link
Member

Thanks @ayushman1210 - I'll defer to @Alomir for approval.

Copy link
Collaborator

@Alomir Alomir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work! One name change suggestion, but more importantly a possible way to work around the false clang error.

@ayushman1210
Copy link
Contributor Author

hey @Alomir please review this PR when you have some free time I have made changes as you suggested
thanks !!

@ayushman1210 ayushman1210 requested a review from Alomir January 21, 2026 19:32
@ayushman1210
Copy link
Contributor Author

Hi @Alomir ,
Just nudging this PR #225 up your inbox 🙂 – looking forward to your feedback when you get a chance.
Appreciate it!

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.

3 participants