]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Plus/Source/FreeRTOS-Plus-IoT-SDK/c_sdk/standard/mqtt/src/iot_mqtt_static_memory.c
Rename \FreeRTOS-Plus\Source\FreeRTOS-Plus-IoT-SDK to \FreeRTOS-Plus\Source\FreeRTOS...
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-IoT-SDK / c_sdk / standard / mqtt / src / iot_mqtt_static_memory.c
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-IoT-SDK/c_sdk/standard/mqtt/src/iot_mqtt_static_memory.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-IoT-SDK/c_sdk/standard/mqtt/src/iot_mqtt_static_memory.c
deleted file mode 100644 (file)
index 000fcba..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/*\r
- * Amazon FreeRTOS MQTT V2.0.0\r
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
- * this software and associated documentation files (the "Software"), to deal in\r
- * the Software without restriction, including without limitation the rights to\r
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
- * the Software, and to permit persons to whom the Software is furnished to do so,\r
- * subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included in all\r
- * copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- *\r
- * http://aws.amazon.com/freertos\r
- * http://www.FreeRTOS.org\r
- */\r
-\r
-/**\r
- * @file iot_mqtt_static_memory.c\r
- * @brief Implementation of MQTT static memory functions.\r
- */\r
-\r
-/* The config header is always included first. */\r
-#include "iot_config.h"\r
-\r
-/* This file should only be compiled if dynamic memory allocation is forbidden. */\r
-#if IOT_STATIC_MEMORY_ONLY == 1\r
-\r
-/* Standard includes. */\r
-#include <stdbool.h>\r
-#include <stddef.h>\r
-#include <string.h>\r
-\r
-/* Static memory include. */\r
-#include "private/iot_static_memory.h"\r
-\r
-/* MQTT internal include. */\r
-#include "private/iot_mqtt_internal.h"\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-/**\r
- * @cond DOXYGEN_IGNORE\r
- * Doxygen should ignore this section.\r
- *\r
- * Provide default values for undefined configuration constants.\r
- */\r
-#ifndef IOT_MQTT_CONNECTIONS\r
-    #define IOT_MQTT_CONNECTIONS                   ( 1 )\r
-#endif\r
-#ifndef IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS\r
-    #define IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS    ( 10 )\r
-#endif\r
-#ifndef IOT_MQTT_SUBSCRIPTIONS\r
-    #define IOT_MQTT_SUBSCRIPTIONS                 ( 8 )\r
-#endif\r
-/** @endcond */\r
-\r
-/* Validate static memory configuration settings. */\r
-#if IOT_MQTT_CONNECTIONS <= 0\r
-    #error "IOT_MQTT_CONNECTIONS cannot be 0 or negative."\r
-#endif\r
-#if IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS <= 0\r
-    #error "IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS cannot be 0 or negative."\r
-#endif\r
-#if IOT_MQTT_SUBSCRIPTIONS <= 0\r
-    #error "IOT_MQTT_SUBSCRIPTIONS cannot be 0 or negative."\r
-#endif\r
-\r
-/**\r
- * @brief The size of a static memory MQTT subscription.\r
- *\r
- * Since the pTopic member of #_mqttSubscription_t is variable-length, the constant\r
- * #AWS_IOT_MQTT_SERVER_MAX_TOPIC_LENGTH is used for the length of\r
- * #_mqttSubscription_t.pTopicFilter.\r
- */\r
-#define MQTT_SUBSCRIPTION_SIZE    ( sizeof( _mqttSubscription_t ) + AWS_IOT_MQTT_SERVER_MAX_TOPIC_LENGTH )\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-/*\r
- * Static memory buffers and flags, allocated and zeroed at compile-time.\r
- */\r
-static bool _pInUseMqttConnections[ IOT_MQTT_CONNECTIONS ] = { 0 };                               /**< @brief MQTT connection in-use flags. */\r
-static _mqttConnection_t _pMqttConnections[ IOT_MQTT_CONNECTIONS ] = { { 0 } };                   /**< @brief MQTT connections. */\r
-\r
-static bool _pInUseMqttOperations[ IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS ] = { 0 };                        /**< @brief MQTT operation in-use flags. */\r
-static _mqttOperation_t _pMqttOperations[ IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS ] = { { .link = { 0 } } }; /**< @brief MQTT operations. */\r
-\r
-static bool _pInUseMqttSubscriptions[ IOT_MQTT_SUBSCRIPTIONS ] = { 0 };                           /**< @brief MQTT subscription in-use flags. */\r
-static char _pMqttSubscriptions[ IOT_MQTT_SUBSCRIPTIONS ][ MQTT_SUBSCRIPTION_SIZE ] = { { 0 } };  /**< @brief MQTT subscriptions. */\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-void * IotMqtt_MallocConnection( size_t size )\r
-{\r
-    int32_t freeIndex = -1;\r
-    void * pNewConnection = NULL;\r
-\r
-    /* Check size argument. */\r
-    if( size == sizeof( _mqttConnection_t ) )\r
-    {\r
-        /* Find a free MQTT connection. */\r
-        freeIndex = IotStaticMemory_FindFree( _pInUseMqttConnections,\r
-                                              IOT_MQTT_CONNECTIONS );\r
-\r
-        if( freeIndex != -1 )\r
-        {\r
-            pNewConnection = &( _pMqttConnections[ freeIndex ] );\r
-        }\r
-    }\r
-\r
-    return pNewConnection;\r
-}\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-void IotMqtt_FreeConnection( void * ptr )\r
-{\r
-    /* Return the in-use MQTT connection. */\r
-    IotStaticMemory_ReturnInUse( ptr,\r
-                                 _pMqttConnections,\r
-                                 _pInUseMqttConnections,\r
-                                 IOT_MQTT_CONNECTIONS,\r
-                                 sizeof( _mqttConnection_t ) );\r
-}\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-void * IotMqtt_MallocOperation( size_t size )\r
-{\r
-    int32_t freeIndex = -1;\r
-    void * pNewOperation = NULL;\r
-\r
-    /* Check size argument. */\r
-    if( size == sizeof( _mqttOperation_t ) )\r
-    {\r
-        /* Find a free MQTT operation. */\r
-        freeIndex = IotStaticMemory_FindFree( _pInUseMqttOperations,\r
-                                              IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS );\r
-\r
-        if( freeIndex != -1 )\r
-        {\r
-            pNewOperation = &( _pMqttOperations[ freeIndex ] );\r
-        }\r
-    }\r
-\r
-    return pNewOperation;\r
-}\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-void IotMqtt_FreeOperation( void * ptr )\r
-{\r
-    /* Return the in-use MQTT operation. */\r
-    IotStaticMemory_ReturnInUse( ptr,\r
-                                 _pMqttOperations,\r
-                                 _pInUseMqttOperations,\r
-                                 IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS,\r
-                                 sizeof( _mqttOperation_t ) );\r
-}\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-void * IotMqtt_MallocSubscription( size_t size )\r
-{\r
-    int32_t freeIndex = -1;\r
-    void * pNewSubscription = NULL;\r
-\r
-    if( size <= MQTT_SUBSCRIPTION_SIZE )\r
-    {\r
-        /* Get the index of a free MQTT subscription. */\r
-        freeIndex = IotStaticMemory_FindFree( _pInUseMqttSubscriptions,\r
-                                              IOT_MQTT_SUBSCRIPTIONS );\r
-\r
-        if( freeIndex != -1 )\r
-        {\r
-            pNewSubscription = &( _pMqttSubscriptions[ freeIndex ][ 0 ] );\r
-        }\r
-    }\r
-\r
-    return pNewSubscription;\r
-}\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-void IotMqtt_FreeSubscription( void * ptr )\r
-{\r
-    /* Return the in-use MQTT subscription. */\r
-    IotStaticMemory_ReturnInUse( ptr,\r
-                                 _pMqttSubscriptions,\r
-                                 _pInUseMqttSubscriptions,\r
-                                 IOT_MQTT_SUBSCRIPTIONS,\r
-                                 MQTT_SUBSCRIPTION_SIZE );\r
-}\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-#endif\r