X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=st.c;h=c408ca95af00ea71e2e2cad2ccabb6f977716c34;hb=111199cf226b33f12e6ee3e66e50fbe5c3566e33;hp=d5ecf61fc99a47242f1dac0ef101011346f81d70;hpb=426887ccec8577ee33d1fb44f258d6a70a2eddf1;p=st.git diff --git a/st.c b/st.c index d5ecf61..c408ca9 100644 --- a/st.c +++ b/st.c @@ -324,6 +324,7 @@ static int isfullutf8(char *, int); static void *xmalloc(size_t); static void *xrealloc(void *, size_t); +static void *xcalloc(size_t nmemb, size_t size); static void (*handler[LASTEvent])(XEvent *) = { [KeyPress] = kpress, @@ -362,14 +363,22 @@ void * xmalloc(size_t len) { void *p = malloc(len); if(!p) - die("Out of memory"); + die("Out of memory\n"); return p; } void * xrealloc(void *p, size_t len) { if((p = realloc(p, len)) == NULL) - die("Out of memory"); + die("Out of memory\n"); + return p; +} + +void * +xcalloc(size_t nmemb, size_t size) { + void *p = calloc(nmemb, size); + if(!p) + die("Out of memory\n"); return p; } @@ -1801,8 +1810,8 @@ tresize(int col, int row) { /* allocate any new rows */ for(/* i == minrow */; i < row; i++) { term.dirty[i] = 1; - term.line[i] = calloc(col, sizeof(Glyph)); - term.alt [i] = calloc(col, sizeof(Glyph)); + term.line[i] = xcalloc(col, sizeof(Glyph)); + term.alt [i] = xcalloc(col, sizeof(Glyph)); } if(col > term.col) { bool *bp = term.tabs + term.col;