[Frugalware-git] firepl: add some more functions

James Buren ryuo at frugalware.org
Wed Apr 25 21:48:40 CEST 2012


Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=firepl.git;a=commitdiff;h=644cdc0ba10d9f4f8ec823bd96f076dea04de6de

commit 644cdc0ba10d9f4f8ec823bd96f076dea04de6de
Author: James Buren <ryuo at frugalware.org>
Date:   Wed Apr 25 14:46:00 2012 -0500

add some more functions

diff --git a/utility.c b/utility.c
index fa6cb52..5a2c3c4 100644
--- a/utility.c
+++ b/utility.c
@@ -47,3 +47,20 @@ extern bool _format_string(char *s,size_t n,bool append,const char *fmt,...)

return rv;
}
+
+extern void *_alloc(size_t n,bool zero)
+{
+	void *p;
+
+	assert(n);
+
+	p = malloc(n);
+
+	if(!p)
+		aprintf("Failed to allocate a memory block of %u bytes.\n",n);
+
+	if(zero)
+		memset(p,0,n);
+
+	return p;
+}
diff --git a/utility.h b/utility.h
index b232bac..05d9565 100644
--- a/utility.h
+++ b/utility.h
@@ -19,3 +19,5 @@ typedef enum

extern void _log_message(log_t log,const char *fmt,...);
extern bool _format_string(char *s,size_t n,bool append,const char *fmt,...);
+extern void *_alloc(size_t n,bool zero);
+extern void *_redim(void *p,size_t n);


More information about the Frugalware-git mailing list