Azure IoT common library

Dependents:   STM32F746_iothub_client_sample_mqtt f767zi_mqtt iothub_client_sample_amqp iothub_client_sample_http ... more

Revision:
13:920e00014ee3
Parent:
10:1be0bc9a9deb
Child:
19:2e0811512ceb
diff -r 72001533b0e3 -r 920e00014ee3 socketio_mbed.c
--- a/socketio_mbed.c	Thu Sep 22 18:17:00 2016 -0700
+++ b/socketio_mbed.c	Thu Oct 20 17:08:18 2016 -0700
@@ -10,7 +10,7 @@
 #include <stdio.h>
 #include <string.h>
 #include "azure_c_shared_utility/socketio.h"
-#include "azure_c_shared_utility/list.h"
+#include "azure_c_shared_utility/singlylinkedlist.h"
 #include "azure_c_shared_utility/tcpsocketconnection_c.h"
 #include "azure_c_shared_utility/xlogging.h"
 
@@ -32,7 +32,7 @@
     size_t size;
     ON_SEND_COMPLETE on_send_complete;
     void* callback_context;
-    LIST_HANDLE pending_io_list;
+    SINGLYLINKEDLIST_HANDLE pending_io_list;
 } PENDING_SOCKET_IO;
 
 typedef struct SOCKET_IO_INSTANCE_TAG
@@ -45,7 +45,7 @@
     char* hostname;
     int port;
     IO_STATE io_state;
-    LIST_HANDLE pending_io_list;
+    SINGLYLINKEDLIST_HANDLE pending_io_list;
 } SOCKET_IO_INSTANCE;
 
 /*this function will clone an option given by name and value*/
@@ -121,7 +121,7 @@
             pending_socket_io->pending_io_list = socket_io_instance->pending_io_list;
             (void)memcpy(pending_socket_io->bytes, buffer, size);
 
-            if (list_add(socket_io_instance->pending_io_list, pending_socket_io) == NULL)
+            if (singlylinkedlist_add(socket_io_instance->pending_io_list, pending_socket_io) == NULL)
             {
                 free(pending_socket_io->bytes);
                 free(pending_socket_io);
@@ -151,7 +151,7 @@
         result = malloc(sizeof(SOCKET_IO_INSTANCE));
         if (result != NULL)
         {
-            result->pending_io_list = list_create();
+            result->pending_io_list = singlylinkedlist_create();
             if (result->pending_io_list == NULL)
             {
                 free(result);
@@ -162,7 +162,7 @@
                 result->hostname = (char*)malloc(strlen(socket_io_config->hostname) + 1);
                 if (result->hostname == NULL)
                 {
-                    list_destroy(result->pending_io_list);
+                    singlylinkedlist_destroy(result->pending_io_list);
                     free(result);
                     result = NULL;
                 }
@@ -193,21 +193,21 @@
         tcpsocketconnection_destroy(socket_io_instance->tcp_socket_connection);
 
         /* clear all pending IOs */
-        LIST_ITEM_HANDLE first_pending_io = list_get_head_item(socket_io_instance->pending_io_list);
+        LIST_ITEM_HANDLE first_pending_io = singlylinkedlist_get_head_item(socket_io_instance->pending_io_list);
         while (first_pending_io != NULL)
         {
-            PENDING_SOCKET_IO* pending_socket_io = (PENDING_SOCKET_IO*)list_item_get_value(first_pending_io);
+            PENDING_SOCKET_IO* pending_socket_io = (PENDING_SOCKET_IO*)singlylinkedlist_item_get_value(first_pending_io);
             if (pending_socket_io != NULL)
             {
                 free(pending_socket_io->bytes);
                 free(pending_socket_io);
             }
 
-            (void)list_remove(socket_io_instance->pending_io_list, first_pending_io);
-            first_pending_io = list_get_head_item(socket_io_instance->pending_io_list);
+            (void)singlylinkedlist_remove(socket_io_instance->pending_io_list, first_pending_io);
+            first_pending_io = singlylinkedlist_get_head_item(socket_io_instance->pending_io_list);
         }
 
-        list_destroy(socket_io_instance->pending_io_list);
+        singlylinkedlist_destroy(socket_io_instance->pending_io_list);
         free(socket_io_instance->hostname);
         free(socket_io);
     }
@@ -317,7 +317,7 @@
         }
         else
         {
-            LIST_ITEM_HANDLE first_pending_io = list_get_head_item(socket_io_instance->pending_io_list);
+            LIST_ITEM_HANDLE first_pending_io = singlylinkedlist_get_head_item(socket_io_instance->pending_io_list);
             if (first_pending_io != NULL)
             {
                 if (add_pending_io(socket_io_instance, buffer, size, on_send_complete, callback_context) != 0)
@@ -374,10 +374,10 @@
         {
             int received = 1;
 
-            LIST_ITEM_HANDLE first_pending_io = list_get_head_item(socket_io_instance->pending_io_list);
+            LIST_ITEM_HANDLE first_pending_io = singlylinkedlist_get_head_item(socket_io_instance->pending_io_list);
             while (first_pending_io != NULL)
             {
-                PENDING_SOCKET_IO* pending_socket_io = (PENDING_SOCKET_IO*)list_item_get_value(first_pending_io);
+                PENDING_SOCKET_IO* pending_socket_io = (PENDING_SOCKET_IO*)singlylinkedlist_item_get_value(first_pending_io);
                 if (pending_socket_io == NULL)
                 {
                     socket_io_instance->io_state = IO_STATE_ERROR;
@@ -413,14 +413,14 @@
 
                     free(pending_socket_io->bytes);
                     free(pending_socket_io);
-                    if (list_remove(socket_io_instance->pending_io_list, first_pending_io) != 0)
+                    if (singlylinkedlist_remove(socket_io_instance->pending_io_list, first_pending_io) != 0)
                     {
                         socket_io_instance->io_state = IO_STATE_ERROR;
                         indicate_error(socket_io_instance);
                     }
                 }
 
-                first_pending_io = list_get_head_item(socket_io_instance->pending_io_list);
+                first_pending_io = singlylinkedlist_get_head_item(socket_io_instance->pending_io_list);
             }
 
             while (received > 0)