Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=b126045cde3a5126c42492275d2aab41ead1bcd4
commit b126045cde3a5126c42492275d2aab41ead1bcd4 Author: James Buren <[email protected]> Date: Sat Sep 8 02:56:16 2012 -0500 add a malloc0 function diff --git a/src/local.h b/src/local.h index f1c6031..68a21c6 100644 --- a/src/local.h +++ b/src/local.h @@ -56,6 +56,7 @@ extern bool mkdir_recurse(const char *path); extern bool size_to_string(char *s,size_t n,long long size,bool pad); extern int get_text_length(const char *s); extern bool execute(const char *command,const char *root,pid_t *cpid); +extern void *malloc0(size_t size); extern int get_text_screen_width(const char *s); extern bool get_text_screen_size(const char *text,int *width,int *height); extern bool get_button_screen_size(const char *text,int *width,int *height); diff --git a/src/utility.c b/src/utility.c index 9bd19af..47da87e 100644 --- a/src/utility.c +++ b/src/utility.c @@ -182,6 +182,18 @@ extern bool execute(const char *command,const char *root,pid_t *cpid) return (WEXITSTATUS(status) == 0); } +extern void *malloc0(size_t size) +{ + if(size == 0) + { + errno = EINVAL; + fprintf(logfile,"%s: %s\n",__func__,strerror(errno)); + return 0; + } + + return memset(malloc(size),0,size); +} + extern int get_text_screen_width(const char *s) { wchar_t wc = 0; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
