diff --git a/src/tox-weechat-chats.c b/src/tox-weechat-chats.c index 6ad2e83..54a9b2a 100644 --- a/src/tox-weechat-chats.c +++ b/src/tox-weechat-chats.c @@ -93,7 +93,7 @@ tox_weechat_friend_chat_new(struct t_tox_weechat_identity *identity, tox_get_client_id(identity->tox, friend_number, client_id); // TODO: prepend identity name - char *buffer_name = malloc(TOX_CLIENT_ID_SIZE * 2 + 1); + char buffer_name[TOX_CLIENT_ID_SIZE * 2 + 1]; tox_weechat_bin2hex(client_id, TOX_CLIENT_ID_SIZE, buffer_name); chat->buffer = weechat_buffer_new(buffer_name, @@ -102,8 +102,6 @@ tox_weechat_friend_chat_new(struct t_tox_weechat_identity *identity, tox_weechat_chat_refresh(chat); tox_weechat_chat_add(identity, chat); - free(buffer_name); - return chat; } diff --git a/src/tox-weechat-commands.c b/src/tox-weechat-commands.c index 875d463..ed071cb 100644 --- a/src/tox-weechat-commands.c +++ b/src/tox-weechat-commands.c @@ -87,7 +87,7 @@ tox_weechat_cmd_friend(void *data, struct t_gui_buffer *buffer, uint8_t client_id[TOX_CLIENT_ID_SIZE]; tox_get_client_id(identity->tox, friend_number, client_id); - char *hex_address = malloc(TOX_CLIENT_ID_SIZE * 2 + 1); + char hex_address[TOX_CLIENT_ID_SIZE * 2 + 1]; tox_weechat_bin2hex(client_id, TOX_CLIENT_ID_SIZE, hex_address); @@ -98,7 +98,6 @@ tox_weechat_cmd_friend(void *data, struct t_gui_buffer *buffer, friend_number, name, hex_address); free(name); - free(hex_address); } return WEECHAT_RC_OK; @@ -106,7 +105,7 @@ tox_weechat_cmd_friend(void *data, struct t_gui_buffer *buffer, else if (argc >= 3 && (weechat_strcasecmp(argv[1], "add") == 0)) { - char *address = malloc(TOX_FRIEND_ADDRESS_SIZE); + char address[TOX_FRIEND_ADDRESS_SIZE]; tox_weechat_hex2bin(argv[2], address); char *message; @@ -161,7 +160,6 @@ tox_weechat_cmd_friend(void *data, struct t_gui_buffer *buffer, break; } - return WEECHAT_RC_OK; } @@ -237,7 +235,7 @@ tox_weechat_cmd_friend(void *data, struct t_gui_buffer *buffer, return WEECHAT_RC_OK; } - char *hex_address = malloc(TOX_CLIENT_ID_SIZE * 2 + 1); + char hex_address[TOX_CLIENT_ID_SIZE * 2 + 1]; tox_weechat_bin2hex(request->address, TOX_CLIENT_ID_SIZE, hex_address); @@ -252,7 +250,6 @@ tox_weechat_cmd_friend(void *data, struct t_gui_buffer *buffer, weechat_prefix("network"), accept ? "Accepted" : "Declined", hex_address); - free(hex_address); return WEECHAT_RC_OK; } @@ -277,7 +274,7 @@ tox_weechat_cmd_friend(void *data, struct t_gui_buffer *buffer, request; request = request->next_request) { - char *hex_address = malloc(TOX_CLIENT_ID_SIZE * 2 + 1); + char hex_address[TOX_CLIENT_ID_SIZE * 2 + 1]; tox_weechat_bin2hex(request->address, TOX_CLIENT_ID_SIZE, hex_address); @@ -289,8 +286,6 @@ tox_weechat_cmd_friend(void *data, struct t_gui_buffer *buffer, num, hex_address, num, request->message); - free(hex_address); - ++num; } } @@ -396,7 +391,7 @@ tox_weechat_cmd_myaddress(void *data, struct t_gui_buffer *buffer, uint8_t address[TOX_FRIEND_ADDRESS_SIZE]; tox_get_address(identity->tox, address); - char *address_str = malloc(TOX_FRIEND_ADDRESS_SIZE * 2 + 1); + char address_str[TOX_FRIEND_ADDRESS_SIZE * 2 + 1]; tox_weechat_bin2hex(address, TOX_FRIEND_ADDRESS_SIZE, address_str); weechat_printf(identity->buffer, @@ -404,8 +399,6 @@ tox_weechat_cmd_myaddress(void *data, struct t_gui_buffer *buffer, weechat_prefix("network"), address_str); - free(address_str); - return WEECHAT_RC_OK; } diff --git a/src/tox-weechat-identities.c b/src/tox-weechat-identities.c index f18753a..f5e42ea 100644 --- a/src/tox-weechat-identities.c +++ b/src/tox-weechat-identities.c @@ -140,14 +140,13 @@ tox_weechat_identity_buffer_close_callback(void *data, int tox_weechat_bootstrap_tox(Tox *tox, const char *address, uint16_t port, const char *public_key) { - char *binary_key = malloc(TOX_FRIEND_ADDRESS_SIZE); + char binary_key[TOX_FRIEND_ADDRESS_SIZE]; tox_weechat_hex2bin(public_key, binary_key); int result = tox_bootstrap_from_address(tox, address, port, (uint8_t *)binary_key); - free(binary_key); return result; }