summaryrefslogtreecommitdiff
path: root/src/lib/eet/eet_connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/eet/eet_connection.c')
-rw-r--r--src/lib/eet/eet_connection.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/eet/eet_connection.c b/src/lib/eet/eet_connection.c
index c46f614960..eb83f9c8c2 100644
--- a/src/lib/eet/eet_connection.c
+++ b/src/lib/eet/eet_connection.c
@@ -33,9 +33,9 @@ eet_connection_new(Eet_Read_Cb *eet_read_cb,
33 const void *user_data) 33 const void *user_data)
34{ 34{
35 Eet_Connection *conn; 35 Eet_Connection *conn;
36 36
37 if ((!eet_read_cb) || (!eet_write_cb)) return NULL; 37 if ((!eet_read_cb) || (!eet_write_cb)) return NULL;
38 38
39 conn = calloc(1, sizeof (Eet_Connection)); 39 conn = calloc(1, sizeof (Eet_Connection));
40 if (!conn) return NULL; 40 if (!conn) return NULL;
41 conn->eet_read_cb = eet_read_cb; 41 conn->eet_read_cb = eet_read_cb;
@@ -53,12 +53,12 @@ eet_connection_received(Eet_Connection *conn,
53 do 53 do
54 { 54 {
55 size_t copy_size; 55 size_t copy_size;
56 56
57 if (conn->size == 0) 57 if (conn->size == 0)
58 { 58 {
59 const int *msg; 59 const int *msg;
60 size_t packet_size; 60 size_t packet_size;
61 61
62 if (size < (sizeof(int) * 2)) break; 62 if (size < (sizeof(int) * 2)) break;
63 63
64 msg = data; 64 msg = data;
@@ -76,7 +76,7 @@ eet_connection_received(Eet_Connection *conn,
76 /* Not a partial receive, go the quick way. */ 76 /* Not a partial receive, go the quick way. */
77 if (!conn->eet_read_cb(data, packet_size, conn->user_data)) 77 if (!conn->eet_read_cb(data, packet_size, conn->user_data))
78 break; 78 break;
79 79
80 data = (void *)((char *)data + packet_size); 80 data = (void *)((char *)data + packet_size);
81 size -= packet_size; 81 size -= packet_size;
82 conn->received = 0; 82 conn->received = 0;
@@ -86,7 +86,7 @@ eet_connection_received(Eet_Connection *conn,
86 if (conn->allocated < conn->size) 86 if (conn->allocated < conn->size)
87 { 87 {
88 void *tmp; 88 void *tmp;
89 89
90 tmp = realloc(conn->buffer, conn->size); 90 tmp = realloc(conn->buffer, conn->size);
91 if (!tmp) break; 91 if (!tmp) break;
92 conn->buffer = tmp; 92 conn->buffer = tmp;
@@ -99,15 +99,15 @@ eet_connection_received(Eet_Connection *conn,
99 (conn->size - conn->received >= 99 (conn->size - conn->received >=
100 size) ? size : conn->size - conn->received; 100 size) ? size : conn->size - conn->received;
101 memcpy((char *)conn->buffer + conn->received, data, copy_size); 101 memcpy((char *)conn->buffer + conn->received, data, copy_size);
102 102
103 conn->received += copy_size; 103 conn->received += copy_size;
104 data = (void *)((char *)data + copy_size); 104 data = (void *)((char *)data + copy_size);
105 size -= copy_size; 105 size -= copy_size;
106 106
107 if (conn->received == conn->size) 107 if (conn->received == conn->size)
108 { 108 {
109 size_t data_size; 109 size_t data_size;
110 110
111 data_size = conn->size; 111 data_size = conn->size;
112 conn->size = 0; 112 conn->size = 0;
113 conn->received = 0; 113 conn->received = 0;
@@ -121,7 +121,7 @@ eet_connection_received(Eet_Connection *conn,
121 } 121 }
122 } 122 }
123 while (size > 0); 123 while (size > 0);
124 124
125 return size; 125 return size;
126} 126}
127 127