mirror of
https://github.com/Tha14/toxic.git
synced 2024-12-23 03:13:25 +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 -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)
|
||||
{
|
||||
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"
|
||||
|
||||
/* 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 */
|
||||
struct Recv_Curl_Data {
|
||||
|
@ -41,6 +41,7 @@
|
||||
extern char *DATA_FILE;
|
||||
extern ToxWindow *prompt;
|
||||
extern FriendsList Friends;
|
||||
extern FriendRequests FrndRequests;
|
||||
|
||||
/* command functions */
|
||||
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.num_requests;
|
||||
|
||||
}
|
||||
|
||||
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 SOUNDS_SIZE 10
|
||||
#define ACTIVE_NOTIFS_MAX 50
|
||||
#define ACTIVE_NOTIFS_MAX 10
|
||||
|
||||
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].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 (; i < actives[id].size; i ++) {
|
||||
strcat(formated, actives[id].messages[i]);
|
||||
strcat(formated, "\n");
|
||||
for (size_t i = 0; i < actives[id].size; ++i) {
|
||||
strcat(formatted, actives[id].messages[i]);
|
||||
strcat(formatted, "\n");
|
||||
}
|
||||
|
||||
formated[strlen(formated) - 1] = '\0';
|
||||
|
||||
notify_notification_update(actives[id].box, actives[id].title, formated, NULL);
|
||||
notify_notification_update(actives[id].box, actives[id].title, formatted, NULL);
|
||||
notify_notification_show(actives[id].box, NULL);
|
||||
|
||||
free(formatted);
|
||||
|
||||
control_unlock();
|
||||
|
||||
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].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 (; i < actives[id].size; i ++) {
|
||||
strcat(formated, actives[id].messages[i]);
|
||||
strcat(formated, "\n");
|
||||
for (size_t i = 0; i < actives[id].size; ++i) {
|
||||
strcat(formatted, actives[id].messages[i]);
|
||||
strcat(formatted, "\n");
|
||||
}
|
||||
|
||||
formated[strlen(formated) - 1] = '\0';
|
||||
|
||||
notify_notification_update(actives[id].box, actives[id].title, formated, NULL);
|
||||
notify_notification_update(actives[id].box, actives[id].title, formatted, NULL);
|
||||
notify_notification_show(actives[id].box, NULL);
|
||||
|
||||
free(formatted);
|
||||
|
||||
control_unlock();
|
||||
|
||||
return id;
|
||||
|
@ -26,22 +26,20 @@
|
||||
#include "toxic.h"
|
||||
#include "windows.h"
|
||||
|
||||
#define MAX_FRIEND_REQUESTS 32
|
||||
#define MAX_FRIEND_REQUESTS 20
|
||||
|
||||
struct friend_request {
|
||||
bool active;
|
||||
char msg[MAX_STR_SIZE];
|
||||
char msg[TOX_MAX_FRIEND_REQUEST_LENGTH + 1];
|
||||
uint8_t key[TOX_PUBLIC_KEY_SIZE];
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct FriendRequests {
|
||||
int max_idx;
|
||||
int num_requests;
|
||||
struct friend_request request[MAX_FRIEND_REQUESTS];
|
||||
} FriendRequests;
|
||||
|
||||
extern FriendRequests FrndRequests;
|
||||
|
||||
ToxWindow *new_prompt(void);
|
||||
|
||||
void prep_prompt_win(void);
|
||||
|
Loading…
Reference in New Issue
Block a user