provisioning: Fixed memory leak 23/22223/7
authorGeorge Nash <george.nash@intel.com>
Mon, 28 Aug 2017 23:25:21 +0000 (16:25 -0700)
committerNathan Heldt-Sheller <nathan.heldt-sheller@intel.com>
Tue, 19 Sep 2017 15:45:14 +0000 (15:45 +0000)
commitdab3e302970a77e66f755ee5279fd910e65d1057
treebb15aec2bcaca23e8cf2630b9a7a2452ebf4246e
parent982a008de493a990895e32c3ea1cc9fd3ad774f0
provisioning: Fixed memory leak

Fixed memory leak found using valgrind. The memory
leak was due to the provisionInit function calling
sqlite3_open_v2 without calling sqlite3_close

There was not provisionClose method in the C++ so it was
added to the OCSecure class. To do this OCClosePM was
also added to that the code could be used in Windows.

The provisioningClose call was added to all of the samples
that are currently calling provisioningInit(dbfile)

While updating the some of the android samples the
tab depth was cleaned.

Note the unit tests are not following one of the most
basic rules of unit testing. Tests should be isolated
and independent. When the cleanup code was added to the
unit tests it broke tests that run later. Each individual
unit test should be able to run independent of all the
other unit tests order should not matter. This commit
does a little to break the dependency tests have on other
tests, but it did not fix it completely. Many tests rely
on the DB being left in a state by another test as well as
passing test state to global variables that hold information
outside the individual test.

Change-Id: Id2c05ecc611516a5cf892ae70bb4e0cd0c115752
Signed-off-by: George Nash <george.nash@intel.com>
23 files changed:
java/common/src/main/java/org/iotivity/base/OcProvisioning.java
java/examples-android/DirectPairing/src/main/java/org/iotivity/base/examples/DirectPairing/MainActivity.java
java/examples-android/cloudprovisioningclient/src/main/java/org/iotivity/base/examples/cloudprovisioningclient/CloudProvisioningClient.java
java/examples-android/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java
java/jni/JniOcProvisioning.cpp
java/jni/JniOcProvisioning.h
resource/IPCA/src/ocfframework.cpp
resource/IPCA/src/pretendocprovision.cpp
resource/IPCA/unittests/mockOCProvision.cpp
resource/csdk/security/provisioning/include/internal/provisioningdatabasemanager.h
resource/csdk/security/provisioning/include/ocprovisioningmanager.h
resource/csdk/security/provisioning/src/ocprovisioningmanager.c
resource/csdk/security/provisioning/unittest/otmunittest.cpp
resource/csdk/security/provisioning/unittest/provisioningdatabasemanager.cpp
resource/csdk/stack/octbstack_product_secured.def
resource/include/OCProvisioningManager.hpp
resource/provisioning/examples/provisioningclient.cpp
resource/provisioning/examples/subownerclient.cpp
resource/provisioning/src/OCProvisioningManager.cpp
resource/provisioning/unittests/OCProvisioningTest.cpp
service/easy-setup/sampleapp/mediator/android/EasySetup/app/src/main/java/org/iotivity/service/easysetup/EasysetupActivity.java
service/easy-setup/sampleapp/mediator/linux/richsdk_sample/mediator.cpp
service/easy-setup/sampleapp/mediator/linux/richsdk_sample/submediator.cpp