mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 21:53:05 +01:00
Reduce size of some large stack memory allocations
This commit is contained in:
parent
4c302da503
commit
3cdcfbf4e5
@ -306,7 +306,7 @@ static void complete_home_dir(ToxWindow *self, char *path, int pathsize, const c
|
|||||||
* Returns the diff between old len and new len of ctx->line on success.
|
* Returns the diff between old len and new len of ctx->line on success.
|
||||||
* Returns -1 if no matches or more than one match.
|
* Returns -1 if no matches or more than one match.
|
||||||
*/
|
*/
|
||||||
#define MAX_DIRS 512
|
#define MAX_DIRS 75
|
||||||
int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd)
|
int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd)
|
||||||
{
|
{
|
||||||
char b_path[MAX_STR_SIZE + 1];
|
char b_path[MAX_STR_SIZE + 1];
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#define TLS_CIPHER_SUITE_LIST "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK"
|
#define TLS_CIPHER_SUITE_LIST "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK"
|
||||||
|
|
||||||
/* Max size of an http response that we can store in Recv_Data */
|
/* Max size of an http response that we can store in Recv_Data */
|
||||||
#define MAX_RECV_CURL_DATA_SIZE 32767
|
#define MAX_RECV_CURL_DATA_SIZE 1024
|
||||||
|
|
||||||
/* Holds data received from curl lookup */
|
/* Holds data received from curl lookup */
|
||||||
struct Recv_Curl_Data {
|
struct Recv_Curl_Data {
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
extern char *DATA_FILE;
|
extern char *DATA_FILE;
|
||||||
extern ToxWindow *prompt;
|
extern ToxWindow *prompt;
|
||||||
extern FriendsList Friends;
|
extern FriendsList Friends;
|
||||||
|
extern FriendRequests FrndRequests;
|
||||||
|
|
||||||
/* command functions */
|
/* command functions */
|
||||||
void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
|
||||||
@ -87,7 +88,6 @@ void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
|
|||||||
|
|
||||||
FrndRequests.max_idx = i;
|
FrndRequests.max_idx = i;
|
||||||
--FrndRequests.num_requests;
|
--FrndRequests.num_requests;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_add_helper(ToxWindow *self, Tox *m, const char *id_bin, const char *msg)
|
void cmd_add_helper(ToxWindow *self, Tox *m, const char *id_bin, const char *msg)
|
||||||
|
34
src/notify.c
34
src/notify.c
@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
#define MAX_BOX_MSG_LEN 127
|
#define MAX_BOX_MSG_LEN 127
|
||||||
#define SOUNDS_SIZE 10
|
#define SOUNDS_SIZE 10
|
||||||
#define ACTIVE_NOTIFS_MAX 50
|
#define ACTIVE_NOTIFS_MAX 10
|
||||||
|
|
||||||
extern struct user_settings *user_settings;
|
extern struct user_settings *user_settings;
|
||||||
|
|
||||||
@ -754,20 +754,18 @@ int box_notify2(ToxWindow *self, Notification notif, uint64_t flags, int id, con
|
|||||||
actives[id].size++;
|
actives[id].size++;
|
||||||
actives[id].n_timeout = get_unix_time() + Control.notif_timeout / 1000;
|
actives[id].n_timeout = get_unix_time() + Control.notif_timeout / 1000;
|
||||||
|
|
||||||
char formated[128 * 129] = {'\0'};
|
char *formatted = calloc(1, sizeof(char) * ((MAX_BOX_MSG_LEN + 1) * (MAX_BOX_MSG_LEN + 2)));
|
||||||
|
|
||||||
int i = 0;
|
for (size_t i = 0; i < actives[id].size; ++i) {
|
||||||
|
strcat(formatted, actives[id].messages[i]);
|
||||||
for (; i < actives[id].size; i ++) {
|
strcat(formatted, "\n");
|
||||||
strcat(formated, actives[id].messages[i]);
|
|
||||||
strcat(formated, "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
formated[strlen(formated) - 1] = '\0';
|
notify_notification_update(actives[id].box, actives[id].title, formatted, NULL);
|
||||||
|
|
||||||
notify_notification_update(actives[id].box, actives[id].title, formated, NULL);
|
|
||||||
notify_notification_show(actives[id].box, NULL);
|
notify_notification_show(actives[id].box, NULL);
|
||||||
|
|
||||||
|
free(formatted);
|
||||||
|
|
||||||
control_unlock();
|
control_unlock();
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
@ -863,20 +861,18 @@ int box_silent_notify2(ToxWindow *self, uint64_t flags, int id, const char *form
|
|||||||
actives[id].size ++;
|
actives[id].size ++;
|
||||||
actives[id].n_timeout = get_unix_time() + Control.notif_timeout / 1000;
|
actives[id].n_timeout = get_unix_time() + Control.notif_timeout / 1000;
|
||||||
|
|
||||||
char formated[128 * 129] = {'\0'};
|
char *formatted = calloc(1, sizeof(char) * ((MAX_BOX_MSG_LEN + 1) * (MAX_BOX_MSG_LEN + 2)));
|
||||||
|
|
||||||
int i = 0;
|
for (size_t i = 0; i < actives[id].size; ++i) {
|
||||||
|
strcat(formatted, actives[id].messages[i]);
|
||||||
for (; i < actives[id].size; i ++) {
|
strcat(formatted, "\n");
|
||||||
strcat(formated, actives[id].messages[i]);
|
|
||||||
strcat(formated, "\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
formated[strlen(formated) - 1] = '\0';
|
notify_notification_update(actives[id].box, actives[id].title, formatted, NULL);
|
||||||
|
|
||||||
notify_notification_update(actives[id].box, actives[id].title, formated, NULL);
|
|
||||||
notify_notification_show(actives[id].box, NULL);
|
notify_notification_show(actives[id].box, NULL);
|
||||||
|
|
||||||
|
free(formatted);
|
||||||
|
|
||||||
control_unlock();
|
control_unlock();
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
|
@ -26,22 +26,20 @@
|
|||||||
#include "toxic.h"
|
#include "toxic.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
|
|
||||||
#define MAX_FRIEND_REQUESTS 32
|
#define MAX_FRIEND_REQUESTS 20
|
||||||
|
|
||||||
struct friend_request {
|
struct friend_request {
|
||||||
bool active;
|
bool active;
|
||||||
char msg[MAX_STR_SIZE];
|
char msg[TOX_MAX_FRIEND_REQUEST_LENGTH + 1];
|
||||||
uint8_t key[TOX_PUBLIC_KEY_SIZE];
|
uint8_t key[TOX_PUBLIC_KEY_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct FriendRequests {
|
||||||
int max_idx;
|
int max_idx;
|
||||||
int num_requests;
|
int num_requests;
|
||||||
struct friend_request request[MAX_FRIEND_REQUESTS];
|
struct friend_request request[MAX_FRIEND_REQUESTS];
|
||||||
} FriendRequests;
|
} FriendRequests;
|
||||||
|
|
||||||
extern FriendRequests FrndRequests;
|
|
||||||
|
|
||||||
ToxWindow *new_prompt(void);
|
ToxWindow *new_prompt(void);
|
||||||
|
|
||||||
void prep_prompt_win(void);
|
void prep_prompt_win(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user