Track memory allocations using oic_malloc, oic_string.
This will suppress valgrind warning about using delete on C string,
previously, ocEntityHandlerRequest.query was allocated using C strdup,
so free should be used not C++ delete[].
Conflicts:
service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp
Bug: https://jira.iotivity.org/browse/IOT-2267
Origin: https://gerrit.iotivity.org/gerrit/#/c/22129
Change-Id: I86a3a3dfee8492656ee89de5913617369bf1fbb3
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/22129
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Mats Wichmann <mats@linux.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#include "oic_malloc.h"
+#include "oic_string.h"
#include "UnitTestHelperWithFakeOCPlatform.h"
#include "RCSResourceObject.h"
if(!interface.empty())
{
const string query = string("if=" + interface);
- auto cQuery = new char [query.size()+1];
- std::strcpy(cQuery, query.c_str());
- ocEntityHandlerRequest.query = const_cast<char *> (cQuery);
+ ocEntityHandlerRequest.query = OICStrdup(query.c_str());
}
formResourceRequest(OC_REQUEST_FLAG, &ocEntityHandlerRequest, request);
OCRepPayloadDestroy((OCRepPayload *)ocEntityHandlerRequest.payload);
-
- delete[] ocEntityHandlerRequest.query;
+ OICFreeAndSetToNull((void**) &ocEntityHandlerRequest.query);
return request;
}