Skip to content

Commit

Permalink
Merge pull request #130 from niklasva/cpp_teardown_ctx
Browse files Browse the repository at this point in the history
C++ wrapper, only call teardown in destructors if context exists
  • Loading branch information
sidcha authored Sep 3, 2023
2 parents 97b9c11 + 1f293bb commit 3c762ea
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit 3c762ea

Please sign in to comment.