/** * Free a client structure * @param client the client data to free */ void MQTTProtocol_freeClient(Clients* client) { FUNC_ENTRY; /* free up pending message lists here, and any other allocated data */ MQTTProtocol_freeMessageList(client->outboundMsgs); MQTTProtocol_freeMessageList(client->inboundMsgs); ListFree(client->messageQueue); free(client->clientID); if (client->will) { free(client->will->payload); free(client->will->topic); free(client->will); } #if defined(OPENSSL) if (client->sslopts) { if (client->sslopts->trustStore) free((void*)client->sslopts->trustStore); if (client->sslopts->keyStore) free((void*)client->sslopts->keyStore); if (client->sslopts->privateKey) free((void*)client->sslopts->privateKey); if (client->sslopts->privateKeyPassword) free((void*)client->sslopts->privateKeyPassword); if (client->sslopts->enabledCipherSuites) free((void*)client->sslopts->enabledCipherSuites); free(client->sslopts); } #endif /* don't free the client structure itself... this is done elsewhere */ FUNC_EXIT; }
/** * Free a client structure * @param client the client data to free */ void MQTTProtocol_freeClient(Clients* client) { int i; FUNC_ENTRY; MQTTProtocol_removeAllSubscriptions(client->clientID); /* free up pending message lists here, and any other allocated data */ MQTTProtocol_freeMessageList(client->outboundMsgs); MQTTProtocol_freeMessageList(client->inboundMsgs); if (queuedMsgsCount(client) > 0) Log(LOG_WARNING, 64, NULL, queuedMsgsCount(client), client->clientID); for (i = 0; i < PRIORITY_MAX; ++i) MQTTProtocol_freeMessageList(client->queuedMsgs[i]); #if defined(MQTTS) if (client->registrations != NULL) MQTTSProtocol_freeRegistrationList(client->registrations); if (client->pendingRegistration != NULL) free(client->pendingRegistration); if (client->wirelessNodeId != NULL) free(client->wirelessNodeId); #if !defined(NO_BRIDGE) if (client->pendingSubscription != NULL) { if (client->pendingSubscription->topicName) free(client->pendingSubscription->topicName); free(client->pendingSubscription); } #endif #endif if (client->addr != NULL) free(client->addr); free(client->clientID); if (client->will != NULL) { willMessages* w = client->will; free(w->msg); free(w->topic); free(client->will); } free(client); FUNC_EXIT; }