Skip to content
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

ContextBuilder: solve context close bug using reference count #344

Conversation

Adrian-Stanea
Copy link
Contributor

  • added reference count to ContextBuilder to keep track of how many external references to the M2k context are present. When the last reference is removed, the M2k context can be closed.
  • contexts should be closed in the reverse order they were opened: contextClose() -> iio_context_destroy() to avoid pointer errors.
  • based on context ownership, the user of the API is responsible of deinitalizing resources.

include/libm2k/contextbuilder.hpp Outdated Show resolved Hide resolved
src/contextbuilder.cpp Outdated Show resolved Hide resolved
src/contextbuilder.cpp Outdated Show resolved Hide resolved
src/contextbuilder.cpp Outdated Show resolved Hide resolved
src/contextbuilder.cpp Outdated Show resolved Hide resolved
src/contextbuilder.cpp Outdated Show resolved Hide resolved
@Adrian-Stanea Adrian-Stanea force-pushed the bugFix_context_ownership branch from 0c78649 to 03943ba Compare October 3, 2023 13:15
- added reference count to ContextBuilder to keep track of how many
  external references to the M2k context are present. When the last
  reference is removed, the M2k context can be closed.
- contexts should be closed in the reverse order they were opened:
  contextClose() -> iio_context_destroy() to avoid dangling pointers.

Signed-off-by: Adrian Stanea <Adrian.Stanea@analog.com>
@AlexandraTrifan AlexandraTrifan force-pushed the bugFix_context_ownership branch from 03943ba to da2ce29 Compare January 29, 2024 11:51
@AlexandraTrifan AlexandraTrifan merged commit 2499612 into analogdevicesinc:master Jan 29, 2024
9 of 12 checks passed
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