allocate less
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7630 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
345d5c79ba
commit
d54c936938
|
@ -141,8 +141,6 @@ static switch_status_t load_config(void)
|
|||
|
||||
static void event_handler(switch_event_t *event)
|
||||
{
|
||||
char *buf;
|
||||
size_t len;
|
||||
uint8_t send = 0;
|
||||
|
||||
if (globals.running != 1) {
|
||||
|
@ -154,9 +152,6 @@ static void event_handler(switch_event_t *event)
|
|||
return;
|
||||
}
|
||||
|
||||
buf = (char *) malloc(MULTICAST_BUFFSIZE);
|
||||
switch_assert(buf);
|
||||
|
||||
if (globals.event_list[(uint8_t) SWITCH_EVENT_ALL]) {
|
||||
send = 1;
|
||||
} else if ((globals.event_list[(uint8_t) event->event_id])) {
|
||||
|
@ -170,22 +165,22 @@ static void event_handler(switch_event_t *event)
|
|||
|
||||
switch (event->event_id) {
|
||||
case SWITCH_EVENT_LOG:
|
||||
goto end;
|
||||
return;
|
||||
default:
|
||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Multicast-Sender", "%s", globals.hostname);
|
||||
if (switch_event_serialize(event, &packet, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
|
||||
size_t len = strlen(packet) + sizeof(globals.host_hash);
|
||||
char *buf = malloc(len + 1);
|
||||
switch_assert(buf);
|
||||
memcpy(buf, &globals.host_hash, sizeof(globals.host_hash));
|
||||
switch_copy_string(buf + sizeof(globals.host_hash), packet, MULTICAST_BUFFSIZE - sizeof(globals.host_hash));
|
||||
len = strlen(packet) + sizeof(globals.host_hash);;
|
||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nEVENT\n--------------------------------\n%s\n", buf);
|
||||
switch_copy_string(buf + sizeof(globals.host_hash), packet, len - sizeof(globals.host_hash));
|
||||
switch_socket_sendto(globals.udp_socket, globals.addr, 0, buf, &len);
|
||||
switch_safe_free(packet);
|
||||
switch_safe_free(buf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
end:
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue