Skip to content

Commit 0db53dd

Browse files
authored
Move static arrays from function MQTTAgent_Init to MQTTAgentContext_t. (#132)
1 parent cbe6c9b commit 0db53dd

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

source/core_mqtt_agent.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -973,18 +973,6 @@ MQTTStatus_t MQTTAgent_Init( MQTTAgentContext_t * pMqttAgentContext,
973973
{
974974
MQTTStatus_t returnStatus;
975975

976-
/**
977-
* @brief Array used to maintain the outgoing publish records and their
978-
* state by the coreMQTT library.
979-
*/
980-
static MQTTPubAckInfo_t pIncomingPublishRecords[ MQTT_AGENT_MAX_OUTSTANDING_ACKS ];
981-
982-
/**
983-
* @brief Array used to maintain the outgoing publish records and their
984-
* state by the coreMQTT library.
985-
*/
986-
static MQTTPubAckInfo_t pOutgoingPublishRecords[ MQTT_AGENT_MAX_OUTSTANDING_ACKS ];
987-
988976
if( ( pMqttAgentContext == NULL ) ||
989977
( pMsgInterface == NULL ) ||
990978
( pTransportInterface == NULL ) ||
@@ -1017,9 +1005,9 @@ MQTTStatus_t MQTTAgent_Init( MQTTAgentContext_t * pMqttAgentContext,
10171005
if( returnStatus == MQTTSuccess )
10181006
{
10191007
returnStatus = MQTT_InitStatefulQoS( &( pMqttAgentContext->mqttContext ),
1020-
pOutgoingPublishRecords,
1008+
pMqttAgentContext->pOutgoingPublishRecords,
10211009
MQTT_AGENT_MAX_OUTSTANDING_ACKS,
1022-
pIncomingPublishRecords,
1010+
pMqttAgentContext->pIncomingPublishRecords,
10231011
MQTT_AGENT_MAX_OUTSTANDING_ACKS );
10241012
}
10251013
}

source/include/core_mqtt_agent.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,14 @@ typedef void (* MQTTAgentIncomingPublishCallback_t )( struct MQTTAgentContext *
151151
*/
152152
typedef struct MQTTAgentContext
153153
{
154-
MQTTContext_t mqttContext; /**< MQTT connection information used by coreMQTT. */
155-
MQTTAgentMessageInterface_t agentInterface; /**< Struct of function pointers for agent messaging. */
156-
MQTTAgentAckInfo_t pPendingAcks[ MQTT_AGENT_MAX_OUTSTANDING_ACKS ]; /**< List of pending acknowledgment packets. */
157-
MQTTAgentIncomingPublishCallback_t pIncomingCallback; /**< Callback to invoke for incoming publishes. */
158-
void * pIncomingCallbackContext; /**< Context for incoming publish callback. */
159-
bool packetReceivedInLoop; /**< Whether a MQTT_ProcessLoop() call received a packet. */
154+
MQTTContext_t mqttContext; /**< MQTT connection information used by coreMQTT. */
155+
MQTTAgentMessageInterface_t agentInterface; /**< Struct of function pointers for agent messaging. */
156+
MQTTAgentAckInfo_t pPendingAcks[ MQTT_AGENT_MAX_OUTSTANDING_ACKS ]; /**< List of pending acknowledgment packets. */
157+
MQTTAgentIncomingPublishCallback_t pIncomingCallback; /**< Callback to invoke for incoming publishes. */
158+
void * pIncomingCallbackContext; /**< Context for incoming publish callback. */
159+
bool packetReceivedInLoop; /**< Whether a MQTT_ProcessLoop() call received a packet. */
160+
MQTTPubAckInfo_t pIncomingPublishRecords[ MQTT_AGENT_MAX_OUTSTANDING_ACKS ]; /**< Array used to maintain the incoming publish records and their state by the coreMQTT library. */
161+
MQTTPubAckInfo_t pOutgoingPublishRecords[ MQTT_AGENT_MAX_OUTSTANDING_ACKS ]; /**< Array used to maintain the outgoing publish records and their state by the coreMQTT library. */
160162
} MQTTAgentContext_t;
161163

162164
/**

0 commit comments

Comments
 (0)