all repos — st @ e3671006dba1c21316c570e11d6688f5513fb44e

st (suckless terminal) config

Add xcalloc wrapper

malloc and realloc are called through xmalloc and xrealloc, so calloc should
be called through xcalloc.
---
 st.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
Roberto E. Vargas Caballero k0ga@shike2.com
commit

e3671006dba1c21316c570e11d6688f5513fb44e

parent

426887ccec8577ee33d1fb44f258d6a70a2eddf1

1 files changed, 11 insertions(+), 2 deletions(-)

jump to
M st.cst.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,

@@ -370,6 +371,14 @@ void *

xrealloc(void *p, size_t len) { if((p = realloc(p, len)) == NULL) die("Out of memory"); + 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 @@

/* 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;