From 77511a82b1efe2ecde013b3f20ff71605aa61971 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 19 Nov 2011 00:55:38 -0800 Subject: Remove Malloc wrapper and its MallocFailed helper Only two calls left, one of which was already checking for failure. Signed-off-by: Alan Coopersmith --- misc.c | 21 +-------------------- misc.h | 4 ---- xfwp.c | 6 +++++- 3 files changed, 6 insertions(+), 25 deletions(-) diff --git a/misc.c b/misc.c index d178ae7..5167a1c 100644 --- a/misc.c +++ b/misc.c @@ -71,13 +71,6 @@ Usage(void) exit (0); } -static void -MallocFailed(void) -{ - (void) fprintf(stderr, "Memory allocation failed, exiting\n"); - exit(1); -} - static void BadMalloc( int line) @@ -208,8 +201,7 @@ doInitNewRule( } } - if ((config_lineP = (struct config_line *) - Malloc (sizeof(struct config_line))) == NULL) + if ((config_lineP = malloc (sizeof(struct config_line))) == NULL) { (void) fprintf (stderr, "malloc - config_lineP\n"); return -1; @@ -480,17 +472,6 @@ doProcessLine( /* * Public functions */ -char* -Malloc( - int s) -{ - char *p = malloc(s); - - if (!p) - MallocFailed(); - - return p; -} int doConfigCheck( diff --git a/misc.h b/misc.h index 314ceb2..3b27221 100644 --- a/misc.h +++ b/misc.h @@ -51,10 +51,6 @@ X Window System is a trademark of The Open Group. #define SEPARATOR2 '.' -extern char* -Malloc( - int s); - extern int doConfigCheck( struct sockaddr_in * source_sockaddr_in, diff --git a/xfwp.c b/xfwp.c index b11760f..ca1bcb5 100644 --- a/xfwp.c +++ b/xfwp.c @@ -77,7 +77,11 @@ main ( * without making everything global! See FWPprotocolSetupProc() for * the rest of what we are doing */ - config_info = (struct config *) Malloc(sizeof(struct config)); + if ((config_info = malloc(sizeof(struct config))) == NULL) + { + fprintf(stderr, "Memory allocation failed, exiting\n"); + exit(1); + } global_data.config_info = config_info; global_data.nfds = &nfds; -- cgit v1.2.3