Mercurial > hg
comparison mcabber/src/screen.c @ 153:ae0844311710
[/trunk] Changeset 165 by mikael
* Do check on memory allocation for important data.
* Decrease scr_LogPrint buffer size to 1kb.
author | mikael |
---|---|
date | Sun, 01 May 2005 04:42:07 +0000 |
parents | b69c0b7a23e3 |
children | 8630b7cae87b |
comparison
equal
deleted
inserted
replaced
152:05f606cfb9e4 | 153:ae0844311710 |
---|---|
182 { | 182 { |
183 int x; | 183 int x; |
184 int y; | 184 int y; |
185 int lines; | 185 int lines; |
186 int cols; | 186 int cols; |
187 window_entry_t *tmp = calloc(1, sizeof(window_entry_t)); | 187 window_entry_t *tmp; |
188 | |
189 do { | |
190 tmp = calloc(1, sizeof(window_entry_t)); | |
191 } while (!tmp); | |
188 | 192 |
189 // Dimensions | 193 // Dimensions |
190 x = ROSTER_WIDTH; | 194 x = ROSTER_WIDTH; |
191 y = 0; | 195 y = 0; |
192 lines = CHAT_WIN_HEIGHT; | 196 lines = CHAT_WIN_HEIGHT; |
193 cols = maxX - ROSTER_WIDTH; | 197 cols = maxX - ROSTER_WIDTH; |
194 | 198 |
195 tmp->win = newwin(lines, cols, y, x); | 199 tmp->win = newwin(lines, cols, y, x); |
196 tmp->panel = new_panel(tmp->win); | 200 tmp->panel = new_panel(tmp->win); |
197 tmp->name = (char *) calloc(1, 1024); | 201 tmp->name = (char *) calloc(1, 96); |
198 strncpy(tmp->name, title, 1024); | 202 strncpy(tmp->name, title, 96); |
199 scr_clear_box(tmp->win, 0, 0, lines, cols, COLOR_GENERAL); | 203 scr_clear_box(tmp->win, 0, 0, lines, cols, COLOR_GENERAL); |
200 | 204 |
201 if (!dont_show) { | 205 if (!dont_show) { |
202 currentWindow = tmp; | 206 currentWindow = tmp; |
203 } else { | 207 } else { |
926 { | 930 { |
927 time_t timestamp; | 931 time_t timestamp; |
928 char *buffer; | 932 char *buffer; |
929 va_list ap; | 933 va_list ap; |
930 | 934 |
931 buffer = (char *) calloc(1, 4096); | 935 do { |
936 buffer = (char *) calloc(1, 1024); | |
937 } while (!buffer); | |
932 | 938 |
933 timestamp = time(NULL); | 939 timestamp = time(NULL); |
934 strftime(buffer, 64, "[%H:%M:%S] ", localtime(×tamp)); | 940 strftime(buffer, 64, "[%H:%M:%S] ", localtime(×tamp)); |
935 wprintw(logWnd, "\n%s", buffer); | 941 wprintw(logWnd, "\n%s", buffer); |
936 | 942 |
937 va_start(ap, fmt); | 943 va_start(ap, fmt); |
938 vsnprintf(buffer, 4096, fmt, ap); | 944 vsnprintf(buffer, 1024, fmt, ap); |
939 va_end(ap); | 945 va_end(ap); |
940 | 946 |
941 wprintw(logWnd, "%s", buffer); | 947 wprintw(logWnd, "%s", buffer); |
942 free(buffer); | 948 free(buffer); |
943 | 949 |