diff --git a/include/telebot-private.h b/include/telebot-private.h index c005349..b4974ef 100644 --- a/include/telebot-private.h +++ b/include/telebot-private.h @@ -21,6 +21,9 @@ #define TELEBOT_API_URL "https://api.telegram.org" #define TELEBOT_URL_SIZE 1024 +#define TELEBOT_BUFFER_SECTOR 512 +#define TELEBOT_BUFFER_BLOCK 1024 +#define TELEBOT_BUFFER_PAGE 4096 #define TELEBOT_UPDATE_COUNT_MAX_LIMIT 100 #define TELEBOT_USER_PROFILE_PHOTOS_LIMIT 100 diff --git a/src/telebot.c b/src/telebot.c index b7d9ecf..29dca59 100644 --- a/src/telebot.c +++ b/src/telebot.c @@ -140,6 +140,8 @@ telebot_error_e telebot_get_updates(telebot_handler_t handle, int offset, int limit, int timeout, telebot_update_type_e allowed_updates[], int allowed_updates_count, telebot_update_t **updates, int *count) { + int i = 0; + char allowed_updates_str[TELEBOT_BUFFER_PAGE] = {0, }; telebot_hdata_t *_handle = (telebot_hdata_t *)handle; if (_handle == NULL) return TELEBOT_ERROR_NOT_SUPPORTED; @@ -150,19 +152,15 @@ telebot_error_e telebot_get_updates(telebot_handler_t handle, int offset, *updates = NULL; *count = 0; - int i = 0; - char allowed_updates_str[1024] = ""; if (allowed_updates_count > 0) { - snprintf(allowed_updates_str, 1024, "%s", "["); + strncat(allowed_updates_str, "[", TELEBOT_BUFFER_BLOCK); for (i=0;ioffset; @@ -313,6 +311,8 @@ telebot_error_e telebot_set_webhook(telebot_handler_t handle, char *url, char *certificate, int max_connections, telebot_update_type_e allowed_updates[], int allowed_updates_count) { + int i = 0; + char allowed_updates_str[TELEBOT_BUFFER_PAGE] = {0, }; telebot_hdata_t * _handle = (telebot_hdata_t *)handle; if (_handle == NULL) return TELEBOT_ERROR_NOT_SUPPORTED; @@ -320,19 +320,15 @@ telebot_error_e telebot_set_webhook(telebot_handler_t handle, char *url, if (url == NULL) return TELEBOT_ERROR_INVALID_PARAMETER; - int i = 0; - char allowed_updates_str[1024] = ""; if (allowed_updates_count > 0) { - snprintf(allowed_updates_str, 1024, "%s", "["); + strncat(allowed_updates_str, "[", TELEBOT_BUFFER_BLOCK); for (i=0;icore_h, url,