-
Notifications
You must be signed in to change notification settings - Fork 48
Free the map target when the object is destroyed #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TSonono
wants to merge
1
commit into
intel:main
Choose a base branch
from
TSonono:free-map-target
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding build errors: one thing you can do is to wrap this in a
group _internal_destructor is destroy
to avoid clashes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a solution, but is it desirable to always and unconditionally free the map target?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would that be preferred? I could fix these particular build errors in pcie-downstream-port and cxl-downstream-port in the base repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the object is deleted, is there any scenario where not freeing the map target makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was about to say. The build issues are due to various sporadic
destroy_tmpl
templates scattered across the repo that was a workaround before thedestroy
template was officially added. These could be addressed by simply cleaning up the old usages ofdestroy_tmpl
and usingdestroy
instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno. I figure not, save, peraps, some extremely bad exotic interactions, which would constitute separate bugs in their own right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or well -- perhaps there'd be merit in making it an overridable method of the connect, because that'd allow the user to act on the connected object before freeing it (by calling
default()
). An internal destructor would make that impossible. But I don't know how realistic such a use case would be.In general, the question of overrides are something to consider. If there is a
destroy()
specified, and the user doesn't calldefault()
(whether they be because the code precedes this PR or because they forgot), then the map target won't get freed. Having an internal destructor object prevents that situation from occurring. Another consideration is thatdestroy
of subobjects are guaranteed to be called first before their parent objects. This means there is no issue if there's a customdestroy
of the connect that also frees the map target -- because this internal destructor will set themap_target
toNULL
, andSIM_free_map_target
is a noop onNULL
.So there are pros and cons here. I'm leaning towards the internal destructor, though.