diff options
| -rw-r--r-- | st.c | 13 |
1 files changed, 11 insertions, 2 deletions
| @@ -324,6 +324,7 @@ static int isfullutf8(char *, int); | |||
| 324 | 324 | ||
| 325 | static void *xmalloc(size_t); | 325 | static void *xmalloc(size_t); |
| 326 | static void *xrealloc(void *, size_t); | 326 | static void *xrealloc(void *, size_t); |
| 327 | static void *xcalloc(size_t nmemb, size_t size); | ||
| 327 | 328 | ||
| 328 | static void (*handler[LASTEvent])(XEvent *) = { | 329 | static void (*handler[LASTEvent])(XEvent *) = { |
| 329 | [KeyPress] = kpress, | 330 | [KeyPress] = kpress, |
| @@ -373,6 +374,14 @@ xrealloc(void *p, size_t len) { | |||
| 373 | return p; | 374 | return p; |
| 374 | } | 375 | } |
| 375 | 376 | ||
| 377 | void * | ||
| 378 | xcalloc(size_t nmemb, size_t size) { | ||
| 379 | void *p = calloc(nmemb, size); | ||
| 380 | if(!p) | ||
| 381 | die("Out of memory\n"); | ||
| 382 | return p; | ||
| 383 | } | ||
| 384 | |||
| 376 | int | 385 | int |
| 377 | utf8decode(char *s, long *u) { | 386 | utf8decode(char *s, long *u) { |
| 378 | uchar c; | 387 | uchar c; |
| @@ -1801,8 +1810,8 @@ tresize(int col, int row) { | |||
| 1801 | /* allocate any new rows */ | 1810 | /* allocate any new rows */ |
| 1802 | for(/* i == minrow */; i < row; i++) { | 1811 | for(/* i == minrow */; i < row; i++) { |
| 1803 | term.dirty[i] = 1; | 1812 | term.dirty[i] = 1; |
| 1804 | term.line[i] = calloc(col, sizeof(Glyph)); | 1813 | term.line[i] = xcalloc(col, sizeof(Glyph)); |
| 1805 | term.alt [i] = calloc(col, sizeof(Glyph)); | 1814 | term.alt [i] = xcalloc(col, sizeof(Glyph)); |
| 1806 | } | 1815 | } |
| 1807 | if(col > term.col) { | 1816 | if(col > term.col) { |
| 1808 | bool *bp = term.tabs + term.col; | 1817 | bool *bp = term.tabs + term.col; |
