|
30 | 30 |
|
31 | 31 | #define TRACE_GROUP "mClt"
|
32 | 32 |
|
| 33 | +#ifdef MBED_CONF_MBED_CLIENT_EVENT_LOOP_SIZE |
| 34 | +#define MBED_CLIENT_EVENT_LOOP_SIZE MBED_CONF_MBED_CLIENT_EVENT_LOOP_SIZE |
| 35 | +#else |
| 36 | +#define MBED_CLIENT_EVENT_LOOP_SIZE 1024 |
| 37 | +#endif |
| 38 | + |
33 | 39 | int8_t M2MConnectionHandlerPimpl::_tasklet_id = -1;
|
34 | 40 |
|
| 41 | +static MemoryPool<M2MConnectionHandlerPimpl::TaskIdentifier, MBED_CLIENT_EVENT_LOOP_SIZE/64> memory_pool; |
| 42 | + |
35 | 43 | extern "C" void connection_tasklet_event_handler(arm_event_s *event)
|
36 | 44 | {
|
37 | 45 | tr_debug("M2MConnectionHandlerPimpl::connection_tasklet_event_handler");
|
@@ -73,7 +81,7 @@ extern "C" void connection_tasklet_event_handler(arm_event_s *event)
|
73 | 81 | break;
|
74 | 82 | }
|
75 | 83 | if (task_id) {
|
76 |
| - free(task_id); |
| 84 | + memory_pool.free(task_id); |
77 | 85 | }
|
78 | 86 | }
|
79 | 87 |
|
@@ -148,7 +156,7 @@ bool M2MConnectionHandlerPimpl::resolve_server_address(const String& server_addr
|
148 | 156 | _server_port = server_port;
|
149 | 157 | _server_type = server_type;
|
150 | 158 | _server_address = server_address;
|
151 |
| - TaskIdentifier* task = (TaskIdentifier*)malloc(sizeof(TaskIdentifier)); |
| 159 | + TaskIdentifier* task = memory_pool.alloc(); |
152 | 160 | if (!task) {
|
153 | 161 | return false;
|
154 | 162 | }
|
@@ -255,7 +263,7 @@ bool M2MConnectionHandlerPimpl::send_data(uint8_t *data,
|
255 | 263 | return false;
|
256 | 264 | }
|
257 | 265 |
|
258 |
| - TaskIdentifier* task = (TaskIdentifier*)malloc(sizeof(TaskIdentifier)); |
| 266 | + TaskIdentifier* task = memory_pool.alloc(); |
259 | 267 | if (!task) {
|
260 | 268 | free(buffer);
|
261 | 269 | return false;
|
@@ -317,9 +325,7 @@ int8_t M2MConnectionHandlerPimpl::connection_tasklet_handler()
|
317 | 325 |
|
318 | 326 | void M2MConnectionHandlerPimpl::socket_event()
|
319 | 327 | {
|
320 |
| - tr_debug("M2MConnectionHandlerPimpl::socket_event()"); |
321 |
| - |
322 |
| - TaskIdentifier* task = (TaskIdentifier*)malloc(sizeof(TaskIdentifier)); |
| 328 | + TaskIdentifier* task = memory_pool.alloc(); |
323 | 329 | if (!task) {
|
324 | 330 | _observer.socket_error(M2MConnectionHandler::SOCKET_READ_ERROR, true);
|
325 | 331 | return;
|
|
0 commit comments