From: Amos Jeffries Date: Mon, 4 Oct 2010 05:44:42 +0000 (-0600) Subject: Revert r10909 X-Git-Tag: take1~212 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c3bf70cd902349e35211ca342878151462bed6ea;p=thirdparty%2Fsquid.git Revert r10909 --- diff --git a/compat/Makefile.am b/compat/Makefile.am index 67c1c4b486..03494f72a4 100644 --- a/compat/Makefile.am +++ b/compat/Makefile.am @@ -11,21 +11,16 @@ include $(top_srcdir)/src/Common.am noinst_LIBRARIES = libcompat-squid.a libcompat_squid_a_SOURCES = \ - assert.cc \ assert.h \ - compat.cc \ compat.h \ compat_shared.h \ cpu.h \ - debug.cc \ debug.h \ drand48.h \ eui64_aton.h \ fdsetsize.h \ getaddrinfo.h \ getnameinfo.h \ - GnuRegex.c \ - GnuRegex.h \ inet_ntop.h \ inet_pton.h \ initgroups.h \ @@ -38,10 +33,6 @@ libcompat_squid_a_SOURCES = \ types.h \ unsafe.h \ valgrind.h \ - xalloc.cc \ - xalloc.h \ - xstring.cc \ - xstring.h \ \ os/aix.h \ os/dragonfly.h \ @@ -58,7 +49,13 @@ libcompat_squid_a_SOURCES = \ os/sgi.h \ os/solaris.h \ os/sunos.h \ - os/windows.h + os/windows.h \ + \ + assert.cc \ + compat.cc \ + debug.cc \ + GnuRegex.h \ + GnuRegex.c libcompat_squid_a_LIBADD= $(LIBOBJS) diff --git a/compat/compat.cc b/compat/compat.cc index e36ae43794..e69de29bb2 100644 --- a/compat/compat.cc +++ b/compat/compat.cc @@ -1,4 +0,0 @@ -#include "config.h" -#include "compat.h" - -void (*failure_notify) (const char *) = NULL; diff --git a/compat/compat_shared.h b/compat/compat_shared.h index 84a4515273..3730b8cd83 100644 --- a/compat/compat_shared.h +++ b/compat/compat_shared.h @@ -17,17 +17,6 @@ * of the requirements for wrapping your hack for safe portability. */ -/* - * Define an error display handler override. - * If error_notify is set by the linked program it will be used by the local - * portability functions. Otherwise perror() will be used. - */ -#ifdef __cplusplus -extern "C" -#else -extern -#endif -void (*failure_notify) (const char *); /* * sys/resource.h and sys/time.h are apparently order-dependant. @@ -205,11 +194,5 @@ extern "C" { #endif #endif -/* - * Several function definitions which we provide for security and code safety. - */ -#include "compat/xalloc.h" -#include "compat/xstring.h" - #endif /* _SQUID_COMPAT_SHARED_H */ diff --git a/compat/xalloc.cc b/compat/xalloc.cc deleted file mode 100644 index 37de8e8919..0000000000 --- a/compat/xalloc.cc +++ /dev/null @@ -1,105 +0,0 @@ -#include "config.h" -#include "compat/xalloc.h" - -void * -xcalloc(size_t n, size_t sz) -{ - void *p; - - if (n < 1) - n = 1; - - if (sz < 1) - sz = 1; - - p = calloc(n, sz); - - if (p == NULL) { - if (failure_notify) { - static char msg[128]; - snprintf(msg, 128, "xcalloc: Unable to allocate %u blocks of %u bytes!\n", - (unsigned int) n, (unsigned int) sz); - msg[127] = '\0'; - (*failure_notify) (msg); - } else { - perror("xcalloc"); - } - exit(1); - } - -#if XMALLOC_DEBUG - check_malloc(p, sz * n); -#endif -#if XMALLOC_STATISTICS - malloc_stat(sz * n); -#endif -#if XMALLOC_TRACE - xmalloc_show_trace(p, 1); -#endif -#if MEM_GEN_TRACE - if (tracefp) - fprintf(tracefp, "c:%u:%u:%p\n", (unsigned int) n, (unsigned int) sz, p); -#endif - - return p; -} - -void * -xmalloc(size_t sz) -{ - void *p; - - if (sz < 1) - sz = 1; - - p = malloc(sz); - - if (p == NULL) { - if (failure_notify) { - static char msg[128]; - snprintf(msg, 128, "xmalloc: Unable to allocate %d bytes!\n", - (int) sz); - msg[127] = '\0'; - (*failure_notify) (msg); - } else { - perror("malloc"); - } - exit(1); - } - -#if XMALLOC_DEBUG - check_malloc(p, sz); -#endif -#if XMALLOC_STATISTICS - malloc_stat(sz); -#endif -#if XMALLOC_TRACE - xmalloc_show_trace(p, 1); -#endif -#if MEM_GEN_TRACE - if (tracefp) - fprintf(tracefp, "m:%d:%p\n", sz, p); -#endif - - return (p); -} - -void -xfree(void *s) -{ -#if XMALLOC_TRACE - xmalloc_show_trace(s, -1); -#endif - - if (s != NULL) { -#if XMALLOC_DEBUG - check_free(s); -#endif - free(s); - } - -#if MEM_GEN_TRACE - if (tracefp && s) - fprintf(tracefp, "f:%p\n", s); -#endif -} diff --git a/compat/xalloc.h b/compat/xalloc.h deleted file mode 100644 index 23d0a5c910..0000000000 --- a/compat/xalloc.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _SQUID_COMPAT_XALLOC_H -#define _SQUID_COMPAT_XALLOC_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * xcalloc() - same as calloc(3). Used for portability. - * Never returns NULL; fatal on error. - * - * Define failure_notify to receive error message. - * otherwise perror() is used to display it. - */ -void *xcalloc(size_t n, size_t sz); - -/** - * xmalloc() - same as malloc(3). Used for portability. - * Never returns NULL; fatal on error. - * - * Define failure_notify to receive error message. - * otherwise perror() is used to display it. - */ -void *xmalloc(size_t sz); - -/** - * xfree() - same as free(3). Used for portability. - * Will not call free(3) if s == NULL. - * - * Define failure_notify to receive error message. - * otherwise perror() is used to display it. - */ -void xfree(void *s); - -#ifdef __cplusplus -} -#endif - -#endif /* _SQUID_COMPAT_XALLOC_H */ diff --git a/compat/xstring.cc b/compat/xstring.cc deleted file mode 100644 index 1e8376cace..0000000000 --- a/compat/xstring.cc +++ /dev/null @@ -1,80 +0,0 @@ -#include "config.h" -#include "compat/xalloc.h" -#include "compat/xstring.h" - -#if HAVE_ERRNO_H -#include -#endif - -char * -xstrdup(const char *s) -{ - size_t sz; - char *p; - - if (s == NULL) { - if (failure_notify) { - (*failure_notify) ("xstrdup: tried to dup a NULL pointer!\n"); - } else { - errno = EINVAL; - perror("xstrdup: tried to dup a NULL pointer!"); - } - exit(1); - } - - /* copy string, including terminating character */ - sz = strlen(s) + 1; - p = (char *)xmalloc(sz); - memcpy(p, s, sz); - - return p; -} - -char * -xstrncpy(char *dst, const char *src, size_t n) -{ - char *r = dst; - - if (!n || !dst) - return dst; - - if (src) - while (--n != 0 && *src != '\0') - *dst++ = *src++; - - *dst = '\0'; - return r; -} - -char * -xstrndup(const char *s, size_t n) -{ - size_t sz; - char *p; - - if (s == NULL) { - errno = EINVAL; - if (failure_notify) { - (*failure_notify) ("xstrndup: tried to dup a NULL pointer!\n"); - } else { - perror("xstrndup: tried to dup a NULL pointer!"); - } - exit(1); - } - if (n < 0) { - errno = EINVAL; - if (failure_notify) { - (*failure_notify) ("xstrndup: tried to dup a negative length string!\n"); - } else { - perror("xstrndup: tried to dup a negative length string!"); - } - exit(1); - } - - sz = strlen(s) + 1; - if (sz > n) - sz = n; - - p = xstrncpy((char *)xmalloc(sz), s, sz); - return p; -} diff --git a/compat/xstring.h b/compat/xstring.h deleted file mode 100644 index 4c8d71ad60..0000000000 --- a/compat/xstring.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _SQUID_COMPAT_XSTRING_H -#define _SQUID_COMPAT_XSTRING_H - -#if HAVE_STRING_H -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * xstrdup() - same as strdup(3). Used for portability. - * Never returns NULL; fatal on error. - * - * Sets errno to EINVAL if a NULL pointer is passed. - * - * Define failure_notify to receive error message. - * otherwise perror() is used to display it. - */ -char *xstrdup(const char *s); - -#ifdef strdup -#undef strdup -#endif -#define strdup(X) xstrdup((X)) - -/* - * xstrncpy() - similar to strncpy(3) but terminates string - * always with '\0' if (n != 0 and dst != NULL), - * and doesn't do padding - */ -char *xstrncpy(char *dst, const char *src, size_t n); - -/** - * xstrndup() - same as strndup(3). Used for portability. - * Never returns NULL; fatal on error. - * - * Sets errno to EINVAL if a NULL pointer or negative - * length is passed. - * - * Define failure_notify to receive error message. - * otherwise perror() is used to display it. - */ -char *xstrndup(const char *s, size_t n); - -#ifdef strndup -#undef strndup -#endif -#define strndup(X) xstrndup((X)) - - -#ifdef __cplusplus -} -#endif - -#endif /* _SQUID_COMPAT_XSTRING_H */ diff --git a/configure.in b/configure.in index 28aedc6ade..98c8be27ba 100644 --- a/configure.in +++ b/configure.in @@ -2112,7 +2112,6 @@ AC_CHECK_HEADERS( \ bstring.h \ cassert \ crypt.h \ - cstdlib \ cstring \ ctype.h \ errno.h \ diff --git a/doc/release-notes/release-3.2.sgml b/doc/release-notes/release-3.2.sgml index 2082977749..85f5f2ed34 100644 --- a/doc/release-notes/release-3.2.sgml +++ b/doc/release-notes/release-3.2.sgml @@ -301,22 +301,19 @@ This section gives a thorough account of those changes in three categories: New tags