mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-10 17:43:39 +08:00
Patch #9307: Replace mem_malloc+memset with mem_calloc
Aside from reducing source code, on systems which use MEM_LIBC_MALLOC, this has the potential to improve performance depending on the underlying memory allocator See http://stackoverflow.com/questions/2688466/why-mallocmemset-is-slower-than-calloc
This commit is contained in:
@@ -1238,11 +1238,7 @@ mqtt_set_inpub_callback(mqtt_client_t *client, mqtt_incoming_publish_cb_t pub_cb
|
||||
mqtt_client_t *
|
||||
mqtt_client_new(void)
|
||||
{
|
||||
mqtt_client_t *client = (mqtt_client_t *)mem_malloc(sizeof(mqtt_client_t));
|
||||
if (client != NULL) {
|
||||
memset(client, 0, sizeof(mqtt_client_t));
|
||||
}
|
||||
return client;
|
||||
return (mqtt_client_t *)mem_calloc(1, sizeof(mqtt_client_t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user