Introduction
Introduction Statistics Contact Development Disclaimer Help
tAdd xcalloc wrapper - st - [fork] customized build of st, the simple terminal
git clone git://src.adamsgaard.dk/st
Log
Files
Refs
README
LICENSE
---
commit e3671006dba1c21316c570e11d6688f5513fb44e
parent 426887ccec8577ee33d1fb44f258d6a70a2eddf1
Author: Roberto E. Vargas Caballero <[email protected]>
Date: Mon, 17 Sep 2012 22:11:20 +0200
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(-)
Diffstat:
M st.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/st.c b/st.c
t@@ -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,
t@@ -373,6 +374,14 @@ xrealloc(void *p, size_t len) {
return p;
}
+void *
+xcalloc(size_t nmemb, size_t size) {
+ void *p = calloc(nmemb, size);
+ if(!p)
+ die("Out of memory\n");
+ return p;
+}
+
int
utf8decode(char *s, long *u) {
uchar c;
t@@ -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;
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.