summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorQball Cow <qball@gmpclient.nl>2014-04-24 14:25:18 +0200
committerQball Cow <qball@gmpclient.nl>2014-04-24 14:25:18 +0200
commit46309a6fd5cc696f356025e794fc8ae67eb95cda (patch)
tree7d9fd10fe7f7a531779ea20b0ed8e475920e512c /source
parentbb119f6831a67732ae2ef91c8d89215e60e5840d (diff)
Replace malloc/memset with calloc.
Diffstat (limited to 'source')
-rw-r--r--source/rofi.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/source/rofi.c b/source/rofi.c
index a614c93e..049b368e 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -128,8 +128,15 @@ void* allocate_clear ( unsigned long bytes )
return NULL;
}
- void *ptr = allocate ( bytes );
- memset ( ptr, 0, bytes );
+ // malloc+memset we can do in one call using calloc.
+ void *ptr = calloc ( bytes, 1 );
+
+ if ( !ptr )
+ {
+ fprintf ( stderr, "calloc failed!\n" );
+ exit ( EXIT_FAILURE );
+ }
+
return ptr;
}
void* reallocate ( void *ptr, unsigned long bytes )