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

C++ wrapper, only call teardown in destructors if context exists #130

Merged
merged 2 commits into from
Sep 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions include/osdp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ class ControlPanel : public Common {
public:
ControlPanel()
{
_ctx = nullptr;
}

~ControlPanel()
{
osdp_cp_teardown(_ctx);
if (_ctx) {
osdp_cp_teardown(_ctx);
}
}

bool setup(int num_pd, osdp_pd_info_t *info)
Expand Down Expand Up @@ -108,11 +111,14 @@ class PeripheralDevice : public Common {
public:
PeripheralDevice()
{
_ctx = nullptr;
}

~PeripheralDevice()
{
osdp_pd_teardown(_ctx);
if (_ctx) {
osdp_pd_teardown(_ctx);
}
}

bool setup(osdp_pd_info_t *info)
Expand Down
Loading