Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for https://github.com/ARMmbed/mbed-os-example-client/issues/75 #2539

Merged
merged 1 commit into from
Aug 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@

#define TRACE_GROUP "mClt"

#ifdef MBED_CONF_MBED_CLIENT_EVENT_LOOP_SIZE
#define MBED_CLIENT_EVENT_LOOP_SIZE MBED_CONF_MBED_CLIENT_EVENT_LOOP_SIZE
#else
#define MBED_CLIENT_EVENT_LOOP_SIZE 1024
#endif

int8_t M2MConnectionHandlerPimpl::_tasklet_id = -1;

static MemoryPool<M2MConnectionHandlerPimpl::TaskIdentifier, MBED_CLIENT_EVENT_LOOP_SIZE/64> memory_pool;

extern "C" void connection_tasklet_event_handler(arm_event_s *event)
{
tr_debug("M2MConnectionHandlerPimpl::connection_tasklet_event_handler");
Expand Down Expand Up @@ -74,7 +82,7 @@ extern "C" void connection_tasklet_event_handler(arm_event_s *event)
break;
}
if (task_id) {
free(task_id);
memory_pool.free(task_id);
}
}

Expand Down Expand Up @@ -145,7 +153,7 @@ bool M2MConnectionHandlerPimpl::resolve_server_address(const String& server_addr
_server_port = server_port;
_server_type = server_type;
_server_address = server_address;
TaskIdentifier* task = (TaskIdentifier*)malloc(sizeof(TaskIdentifier));
TaskIdentifier* task = memory_pool.alloc();
if (!task) {
return false;
}
Expand Down Expand Up @@ -248,7 +256,7 @@ bool M2MConnectionHandlerPimpl::send_data(uint8_t *data,
return false;
}

TaskIdentifier* task = (TaskIdentifier*)malloc(sizeof(TaskIdentifier));
TaskIdentifier* task = memory_pool.alloc();
if (!task) {
free(buffer);
return false;
Expand Down Expand Up @@ -310,9 +318,7 @@ int8_t M2MConnectionHandlerPimpl::connection_tasklet_handler()

void M2MConnectionHandlerPimpl::socket_event()
{
tr_debug("M2MConnectionHandlerPimpl::socket_event()");

TaskIdentifier* task = (TaskIdentifier*)malloc(sizeof(TaskIdentifier));
TaskIdentifier* task = memory_pool.alloc();
if (!task) {
_observer.socket_error(M2MConnectionHandler::SOCKET_READ_ERROR, true);
return;
Expand Down