return fopen(data_dir, mode);
}
+static OCProvisionDev_t* _clone_ocprovision_dev(const OCProvisionDev_t* src)
+{
+ MA_LOGD("");
+
+ if (!src)
+ {
+ MA_LOGD("Invalid parameter");
+ return NULL;
+ }
+
+ OCProvisionDev_t* newDev = g_try_malloc0(sizeof(OCProvisionDev_t));
+
+ memcpy(&newDev->endpoint, &src->endpoint, sizeof(OCDevAddr));
+
+ if (src->pstat)
+ {
+ newDev->pstat= g_try_malloc0(sizeof(OicSecPstat_t));
+
+ memcpy(newDev->pstat, src->pstat, sizeof(OicSecPstat_t));
+ // We have to assign NULL for not necessary information to prevent memory corruption.
+ newDev->pstat->sm = g_try_malloc0(sizeof(OicSecDpom_t));
+ memcpy(newDev->pstat->sm, src->pstat->sm, sizeof(OicSecDpom_t));
+ }
+
+ if (src->doxm)
+ {
+ newDev->doxm = g_try_malloc0(sizeof(OicSecDoxm_t));
+
+ memcpy(newDev->doxm, src->doxm, sizeof(OicSecDoxm_t));
+
+ newDev->doxm->oxmType = g_try_malloc0(src->doxm->oxmTypeLen + 1);
+ memcpy(newDev->doxm->oxmType, src->doxm->oxmType,
+ src->doxm->oxmTypeLen);
+
+ newDev->doxm->oxm = g_try_malloc0(sizeof(OicSecOxm_t));
+ memcpy(newDev->doxm->oxm, src->doxm->oxm, sizeof(OicSecOxm_t));
+
+ newDev->doxm->mom = g_try_malloc0(sizeof(OicSecMom_t));
+ memcpy(newDev->doxm->mom, src->doxm->mom, sizeof(OicSecMom_t));
+
+ if (src->doxm->subOwners) {
+ OicSecSubOwner_t* subowner = NULL;
+ OicSecSubOwner_t* temp = NULL;
+ OicSecSubOwner_t* temp2 = NULL;
+ LL_FOREACH_SAFE(src->doxm->subOwners, subowner, temp) {
+ temp2 = g_try_malloc0(sizeof(OicSecSubOwner_t));
+ memcpy(temp2, subowner, sizeof(OicSecSubOwner_t));
+ LL_APPEND(newDev->doxm->subOwners, temp2);
+ }
+ }
+ }
+
+ if (0 == strlen(src->secVer))
+ {
+ g_strlcpy(newDev->secVer, "0.0.0", OIC_SEC_MAX_VER_LEN);
+ }
+ else
+ {
+ g_strlcpy(newDev->secVer, src->secVer, OIC_SEC_MAX_VER_LEN);
+ }
+
+ newDev->securePort = src->securePort;
+ newDev->devStatus = src->devStatus;
+ newDev->connType = src->connType;
+ newDev->next = NULL;
+
+ return newDev;
+}
+
#ifdef THREAD_COND_WAIT_USED
/*
* data structure
ma_check_null_ret("g_client", g_client);
if (g_client->g_motdev_list) {
- //OCDeleteDiscoveredDevices(g_client->g_motdev_list);
+ OCDeleteDiscoveredDevices(g_client->g_motdev_list);
g_client->g_motdev_list = NULL;
}
}
OCProvisionDev_t *temp2;
OCProvisionDev_t *temp = iter;
temp->next = NULL;
- temp2 = PMCloneOCProvisionDev(temp);
- temp2->next = dev_list;
- dev_list = temp2;
+ temp2 = _clone_ocprovision_dev(temp);
+ LL_APPEND(dev_list, temp2);
/* Notify Mot Enabled Device added */
g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));