From 949a8d0b46d6baa9f42c2f8c3bd5e3bdc3596cbd Mon Sep 17 00:00:00 2001 From: m0gg Date: Sun, 19 Nov 2006 09:40:14 +0000 Subject: nanohttp admin patch; code cleanup --- nanohttp/nanohttp-common.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'nanohttp/nanohttp-common.c') diff --git a/nanohttp/nanohttp-common.c b/nanohttp/nanohttp-common.c index 0784684..ebba360 100644 --- a/nanohttp/nanohttp-common.c +++ b/nanohttp/nanohttp-common.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-common.c,v 1.30 2006/07/09 16:24:19 snowdrop Exp $ +* $Id: nanohttp-common.c,v 1.31 2006/11/19 09:40:14 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -41,6 +41,10 @@ #include #endif +#ifdef HAVE_ERRNO_H +#include +#endif + #ifdef HAVE_CTYPE_H #include #endif @@ -49,10 +53,6 @@ #include #endif -#ifdef MEM_DEBUG -#include -#endif - #include "nanohttp-common.h" #include "nanohttp-logging.h" @@ -90,16 +90,22 @@ herror_t herror_new(const char *func, int errcode, const char *format, ...) { va_list ap; + herror_impl_t *impl; + + if (!(impl = (herror_impl_t *) malloc(sizeof(herror_impl_t)))) + { + log_error2("malloc failed (%s)", strerror(errno)); + return NULL; + } - herror_impl_t *impl = (herror_impl_t *) malloc(sizeof(herror_impl_t)); impl->errcode = errcode; strcpy(impl->func, func); + va_start(ap, format); vsprintf(impl->message, format, ap); va_end(ap); return (herror_t) impl; - } int -- cgit v1.1-32-gdbae