Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwpl.git;a=commitdiff;h=dfe4c26bd88638d44dea6a8f463b1f1c83a99a05

commit dfe4c26bd88638d44dea6a8f463b1f1c83a99a05
Author: James Buren <r...@frugalware.org>
Date:   Mon Sep 21 12:29:24 2009 -0500

utility.c
* add xmalloc function

diff --git a/src/utility.c b/src/utility.c
index 50475a9..8e9a4bd 100644
--- a/src/utility.c
+++ b/src/utility.c
@@ -1,4 +1,5 @@
//[of]:includes
+#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <iso646.h>
@@ -6,6 +7,22 @@
#include "utility.h"
//[cf]
//[of]:functions
+//[of]:xmalloc
+void *xmalloc(size_t size) {
+  void *ptr;
+
+  assert((size > 0));
+
+  ptr = malloc(size);
+
+  if(!ptr) {
+    eprintf("Failed to allocate memory block of %u bytes.\n",size);
+    abort();
+  }
+
+  return ptr;
+}
+//[cf]
//[of]:eprintf
int eprintf(const char *fmt,...) {
va_list args;
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to