#define _GNU_SOURCE 1
#endif
+#define SQUID_NO_ALLOC_PROTECT 1
#include "config.h"
#if USE_GNUREGEX /* only if squid needs it. Usually not */
osdetect.h \
stdvarargs.h \
types.h \
+ unsafe.h \
valgrind.h \
\
os/aix.h \
os/hpux.h \
os/linux.h \
os/mswin.h \
+ os/netbsd.h \
os/next.h \
os/openbsd.h \
os/os2.h \
#include "compat/os/hpux.h"
#include "compat/os/linux.h"
#include "compat/os/mswin.h"
+#include "compat/os/netbsd.h"
#include "compat/os/next.h"
#include "compat/os/openbsd.h"
#include "compat/os/os2.h"
*/
#include "compat/GnuRegex.h"
+/* some functions are unsafe to be used in Squid. */
+#include "compat/unsafe.h"
#endif /* _SQUID_COMPAT_H */
#if HAVE_DIRENT_H
#include <dirent.h>
#define NAMLEN(dirent) strlen((dirent)->d_name)
-
#else /* if not HAVE_DIRENT_H */
#define dirent direct
#define NAMLEN(dirent) (dirent)->d_namlen
#endif
+#ifndef SQUID_NONBLOCK
/* REQUIRED for the below logics. If they move this needs to as well */
#if HAVE_FCNTL_H
#include <fcntl.h>
/** O_NDELAY is our fallback. */
#define SQUID_NONBLOCK O_NDELAY
#endif
-
+#endif
/**
* Signalling flags are apparently not always provided.
/**
- * com_err.h is a C header and needs excplicit shielding, but not
- * all other system headers including this care to do this.
+ * com_err.h is a C header and needs explicit shielding, but not
+ * all other system headers including this care to do so.
*/
#ifdef __cplusplus
#if HAVE_ET_COM_ERR_H
#undef HAVE_MALLOC_H
#endif
+/* Exclude CPPUnit tests from the allocator restrictions. */
+/* BSD implementation uses these still */
+#if defined(SQUID_UNIT_TEST)
+#define SQUID_NO_ALLOC_PROTECT 1
+#endif
#endif /* _SQUID_DRAGONFLY_ */
#endif /* SQUID_OS_DRAGONFLY_H */
#define _etext etext
+/* Exclude CPPUnit tests from the allocator restrictions. */
+/* BSD implementation uses these still */
+#if defined(SQUID_UNIT_TEST)
+#define SQUID_NO_ALLOC_PROTECT 1
+#endif
+
+
#endif /* _SQUID_FREEBSD_ */
#endif /* SQUID_OS_FREEBSD_H */
#define getrusage(a, b) syscall(SYS_GETRUSAGE, a, b)
#endif
+/*
+ * getpagesize(...) not available on HPUX
+ */
+#if !defined(HAVE_GETPAGESIZE)
+#define HAVE_GETPAGESIZE
+#define getpagesize( ) sysconf(_SC_PAGE_SIZE)
+#endif
#endif /* _SQUID_HPUX_ */
#endif /* SQUID_OS_HPUX_H */
#undef ACL
+#if !defined(getpagesize)
+/* Windows may lack getpagesize() prototype */
+SQUIDCEXTERN size_t getpagesize(void);
+#endif
+
#endif /* _SQUID_WIN32_ */
#endif /* SQUID_OS_MSWIN_H */
--- /dev/null
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef SQUID_OS_NETBSD_H
+#define SQUID_OS_NETBSD_H
+
+#ifdef _SQUID_NETBSD_
+
+/****************************************************************************
+ *--------------------------------------------------------------------------*
+ * DO *NOT* MAKE ANY CHANGES below here unless you know what you're doing...*
+ *--------------------------------------------------------------------------*
+ ****************************************************************************/
+
+/* Exclude CPPUnit tests from the allocator restrictions. */
+/* BSD implementation uses these still */
+#if defined(SQUID_UNIT_TEST)
+#define SQUID_NO_ALLOC_PROTECT 1
+#endif
+
+#endif /* _SQUID_NETBSD_ */
+#endif /* SQUID_OS_NETBSD_H */
#undef HAVE_MALLOC_H
#endif
+/* Exclude CPPUnit tests from the allocator restrictions. */
+/* BSD implementation uses these still */
+#if defined(SQUID_UNIT_TEST)
+#define SQUID_NO_ALLOC_PROTECT 1
+#endif
#endif /* _SQUID_OPENBSD_ */
#endif /* SQUID_OS_OPENBSD_H */
****************************************************************************/
+/* O_NONBLOCK requires <fcntl.h> to be included first */
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
/*
* We assume O_NONBLOCK is broken, or does not exist, on SunOS.
*/
--- /dev/null
+#ifndef SQUID_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef _SQUID_COMPAT_UNSAFE_H
+#define _SQUID_COMPAT_UNSAFE_H
+
+/*
+ * Trap unintentional use of functions unsafe for use within squid.
+ */
+
+#if !SQUID_NO_ALLOC_PROTECT
+#ifndef free
+#define free(x) ERROR_free_UNSAFE_IN_SQUID(x)
+#endif
+#ifndef malloc
+#define malloc ERROR_malloc_UNSAFE_IN_SQUID
+#endif
+#ifndef calloc
+#define calloc ERROR_calloc_UNSAFE_IN_SQUID
+#endif
+#endif /* !SQUID_NO_ALLOC_PROTECT */
+
+#if !SQUID_NO_STRING_BUFFER_PROTECT
+#ifndef sprintf
+#define sprintf ERROR_sprintf_UNSAFE_IN_SQUID
+#endif
+#ifndef strdup
+#define strdup ERROR_strdup_UNSAFE_IN_SQUID
+#endif
+#endif /* SQUID_NO_STRING_BUFFER_PROTECT */
+
+#endif /* _SQUID_COMPAT_UNSAFE_H */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#define SQUID_NO_ALLOC_PROTECT 1
-int SMBlib_errno;
-int SMBlib_SMB_Error;
-#define SMBLIB_ERRNO
-#define uchar unsigned char
#include "util.h"
#include "smblib-priv.h"
#include "smblib.h"
#include <string.h>
#include <signal.h>
+#define SMBLIB_ERRNO
+#define uchar unsigned char
+
+int SMBlib_errno;
+int SMBlib_SMB_Error;
SMB_State_Types SMBlib_State;
/* Initialize the SMBlib package */
*/
/* the types are provided by squid's configure preocess */
+#define SQUID_NO_ALLOC_PROTECT 1
#include "config.h"
+
#define BOOL int16_t
#define int16 int16_t
#include <netdb.h>
-#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <signal.h>
SquidMD5Final(digest,&ctx);
for (idx=0; idx<16; idx++)
- sprintf(&sum[idx*2],"%02x",digest[idx]);
+ snprintf(&sum[idx*2],(33-(idx*2)),"%02x",digest[idx]);
sum[32]='\0';
*
* Compile this program with: gcc -o basic_pam_auth basic_pam_auth.cc -lpam -ldl
*/
+#define SQUID_NO_ALLOC_PROTECT 1
+#define SQUID_NO_STRING_BUFFER_PROTECT 1
#include "config.h"
#include "rfc1738.h"
*
* Copyright (c) 2003 Robert Collins <robertc@squid-cache.org>
*/
+#define SQUID_NO_ALLOC_PROTECT 1
+#include "config.h"
#include "text_backend.h"
GSS_C_GSS_CODE, GSS_C_NULL_OID, &msg_ctx, &status_string);
if (maj_stat == GSS_S_COMPLETE) {
if (sizeof(buf) > len + status_string.length + 1) {
- sprintf(buf + len, "%s", (char *) status_string.value);
+ snprintf(buf + len, (sizeof(buf)-len), "%s", (char *) status_string.value);
len += status_string.length;
}
gss_release_buffer(&min_stat, &status_string);
gss_release_buffer(&min_stat, &status_string);
}
if (sizeof(buf) > len + 2) {
- sprintf(buf + len, "%s", ". ");
+ snprintf(buf + len, (sizeof(buf)-len), "%s", ". ");
len += 2;
}
msg_ctx = 0;
GSS_C_MECH_CODE, GSS_C_NULL_OID, &msg_ctx, &status_string);
if (maj_stat == GSS_S_COMPLETE) {
if (sizeof(buf) > len + status_string.length) {
- sprintf(buf + len, "%s", (char *) status_string.value);
+ snprintf(buf + len,(sizeof(buf)-len), "%s", (char *) status_string.value);
len += status_string.length;
}
gss_release_buffer(&min_stat, &status_string);
GSS_C_GSS_CODE, GSS_C_NULL_OID, &msg_ctx, &status_string);
if (maj_stat == GSS_S_COMPLETE) {
if (sizeof(buf) > len + status_string.length + 1) {
- sprintf(buf + len, "%s", (char *) status_string.value);
+ snprintf(buf + len, (sizeof(buf)-len), "%s", (char *)status_string.value);
len += status_string.length;
}
gss_release_buffer(&min_stat, &status_string);
gss_release_buffer(&min_stat, &status_string);
}
if (sizeof(buf) > len + 2) {
- sprintf(buf + len, "%s", ". ");
+ snprintf(buf + len, (sizeof(buf)-len), "%s", ". ");
len += 2;
}
msg_ctx = 0;
GSS_C_MECH_CODE, GSS_C_NULL_OID, &msg_ctx, &status_string);
if (maj_stat == GSS_S_COMPLETE) {
if (sizeof(buf) > len + status_string.length) {
- sprintf(buf + len, "%s", (char *) status_string.value);
+ snprintf(buf + len, (sizeof(buf)-len), "%s", (char *) status_string.value);
len += status_string.length;
}
gss_release_buffer(&min_stat, &status_string);
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
*
*/
-
+#define SQUID_NO_ALLOC_PROTECT 1
#include "config.h"
+
#include "ntlmauth.h"
#include "ntlm_smb_lm_auth.h"
-#include "squid_endian.h"
#include "util.h"
#include "smbval/smblib-common.h"
#include "smbval/rfcnb-error.h"
#define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
-#define SVALS(buf,pos) ((int16)SVAL(buf,pos))
-#define IVALS(buf,pos) ((int32)IVAL(buf,pos))
-#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16)(val)))
-#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val)))
-#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val)))
-#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val)))
+#define SVALS(buf,pos) ((int16_t)SVAL(buf,pos))
+#define IVALS(buf,pos) ((int32_t)IVAL(buf,pos))
+#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16_t)(val)))
+#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32_t)(val)))
+#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16_t)(val)))
+#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32_t)(val)))
#else
/* this handles things for architectures like the 386 that can handle
* alignment errors */
* WARNING: This section is dependent on the length of int16 and int32
* being correct
*/
-#define SVAL(buf,pos) (*(uint16 *)((char *)(buf) + (pos)))
-#define IVAL(buf,pos) (*(uint32 *)((char *)(buf) + (pos)))
-#define SVALS(buf,pos) (*(int16 *)((char *)(buf) + (pos)))
-#define IVALS(buf,pos) (*(int32 *)((char *)(buf) + (pos)))
-#define SSVAL(buf,pos,val) SVAL(buf,pos)=((uint16)(val))
-#define SIVAL(buf,pos,val) IVAL(buf,pos)=((uint32)(val))
-#define SSVALS(buf,pos,val) SVALS(buf,pos)=((int16)(val))
-#define SIVALS(buf,pos,val) IVALS(buf,pos)=((int32)(val))
+#define SVAL(buf,pos) (*(uint16_t *)((char *)(buf) + (pos)))
+#define IVAL(buf,pos) (*(uint32_t *)((char *)(buf) + (pos)))
+#define SVALS(buf,pos) (*(int16_t *)((char *)(buf) + (pos)))
+#define IVALS(buf,pos) (*(int32_t *)((char *)(buf) + (pos)))
+#define SSVAL(buf,pos,val) SVAL(buf,pos)=((uint16_t)(val))
+#define SIVAL(buf,pos,val) IVAL(buf,pos)=((uint32_t)(val))
+#define SSVALS(buf,pos,val) SVALS(buf,pos)=((int16_t)(val))
+#define SIVALS(buf,pos,val) IVALS(buf,pos)=((int32_t)(val))
#endif
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#define SQUID_NO_ALLOC_PROTECT 1
+#include "config.h"
#include <string.h>
-#include <stdlib.h>
#include "std-includes.h"
#include "rfcnb-priv.h"
#include "rfcnb-io.h"
#include <arpa/inet.h>
-#ifndef uint16
-#ifdef u_int16_t
-typedef u_int16_t uint16;
-#else
-typedef unsigned short uint16;
-#endif
-#endif
-
extern void (*Prot_Print_Routine) (); /* Pointer to protocol print routine */
/* Convert name and pad to 16 chars as needed */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#define SQUID_NO_ALLOC_PROTECT 1
+#include "config.h"
#include <string.h>
-#include <stdlib.h>
int RFCNB_errno = 0;
int RFCNB_saved_errno = 0;
void
RFCNB_Get_Error(char *buffer, int buf_len)
{
-
if (RFCNB_saved_errno <= 0) {
- sprintf(buffer, "%s", RFCNB_Error_Strings[RFCNB_errno]);
+ snprintf(buffer, buf_len, "%s", RFCNB_Error_Strings[RFCNB_errno]);
} else {
- sprintf(buffer, "%s\n\terrno:%s", RFCNB_Error_Strings[RFCNB_errno],
+ snprintf(buffer, buf_len, "%s\n\terrno:%s", RFCNB_Error_Strings[RFCNB_errno],
strerror(RFCNB_saved_errno));
}
-
}
/* Pick up the last error response and returns as a code */
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#define SQUID_NO_ALLOC_PROTECT 1
+#include "config.h"
#include "smblib-priv.h"
-#include <stdlib.h>
#include <string.h>
#include "rfcnb.h"
DOS_month = (DOS_time & 0x01E00000) >> 21;
DOS_year = ((DOS_time & 0xFE000000) >> 25) + 80;
- sprintf(SMB_Time_Temp, "%2d/%02d/%2d %2d:%02d:%02d", DOS_day, DOS_month,
+ snprintf(SMB_Time_Temp, 48, "%2d/%02d/%2d %2d:%02d:%02d", DOS_day, DOS_month,
DOS_year, DOS_hour, DOS_min, DOS_sec);
return (SMB_Time_Temp);
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-
+#define SQUID_NO_ALLOC_PROTECT 1
#include "config.h"
-#include <stdlib.h>
+
#include <ctype.h>
#include <string.h>
/**
* Free a element allocated by MemAllocator::alloc()
*/
- virtual void free(void *) = 0;
+ virtual void freeOne(void *) = 0;
virtual char const *objectType() const;
virtual size_t objectSize() const = 0;
/**
* Free a element allocated by MemAllocatorProxy::alloc()
*/
- void free(void *);
+ void freeOne(void *);
int inUseCount() const;
size_t objectSize() const;
void \
CLASS::operator delete (void *address) \
{ \
- Pool().free(address); \
+ Pool().freeOne(address); \
}
/// \ingroup MemPoolsAPI
/**
* Free a element allocated by MemImplementingAllocator::alloc()
*/
- virtual void free(void *);
+ virtual void freeOne(void *);
virtual bool idleTrigger(int shift) const = 0;
virtual void clean(time_t maxage) = 0;
}
void
-MemImplementingAllocator::free(void *obj)
+MemImplementingAllocator::freeOne(void *obj)
{
assert(obj != NULL);
(void) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(obj, obj_size);
}
void
-MemAllocatorProxy::free(void *address)
+MemAllocatorProxy::freeOne(void *address)
{
- getAllocator()->free(address);
+ getAllocator()->freeOne(address);
/* TODO: check for empty, and if so, if the default type has altered,
* switch
*/
-
/*
* $Id$
*
*
*/
-/*
+/**
* CPU Profiling implementation.
*
+ * \par
* This library implements the Probes needed to gather stats.
* See src/ProfStats.c which implements historical recording and
* presentation in CacheMgr.cgi.
*
+ * \par
* For timing we prefer on-CPU ops that retrieve cpu ticks counter.
* For Intel, this is "rdtsc", which is 64-bit counter that virtually
* never wraps. For alpha, this is "rpcc" which is 32-bit counter and
* probename must be added to profiling.h into xprof_type enum list
* with prepended "XPROF_" string.
*
- * Description.
- * PROF gathers stats per probename into structures. It indexes these
+ * \section description Description.
+ * \par PROF
+ * gathers stats per probename into structures. It indexes these
* structures by enum type index in an array.
*
- * PROF records best, best, average and worst values for delta time,
+ * \par PROF
+ * records best, best, average and worst values for delta time,
* also, if UNACCED is defined, it measures "empty" time during which
* no probes are in measuring state. This allows to see time "unaccounted"
* for. If OVERHEAD is defined, additional calculations are made at every
* probe to measure approximate overhead of the probe code itself.
*
+ * \par
* Probe data is stored in linked-list, so the more probes you define,
* the more overhead is added to find the deepest nested probe. To reduce
* average overhead, linked list is manipulated each time PR_start is
* fast and frequent sections of code, we want to reduce this overhead
* to absolute minimum possible.
*
+ * \par
* For actual measurements, probe overhead cancels out mostly. Still,
* do not take the measured times as facts, they should be viewed in
* relative comparison to overall CPU time and on the same platform.
*
+ * \par
* Every 1 second, Event within squid is called that parses gathered
* statistics of every probe, and accumulates that into historical
* structures for last 1,5,30 secs, 1,5,30 mins, and 1,5 and 24 hours.
* Each second active probe stats are reset, and only historical data
* is presented in cachemgr output.
*
- * Reading stats.
+ * \section reading Reading stats.
+ * \par
* "Worst case" may be misleading. Anything can happen at any section
* of code that could delay reaching to probe stop. For eg. system may
* need to service interrupt routine, task switch could occur, or page
* in given section of code, and its average completion time. This data
* could be used to detect bottlenecks withing squid and optimise them.
*
+ * \par
* TOTALS are quite off reality. Its there just to summarise cumulative
* times and percent column. Percent values over 100% shows that there
* have been some probes nested into each other.
*
*/
-#include "profiling.h"
-
-#include <assert.h>
+#define SQUID_NO_ALLOC_PROTECT 1
+#include "config.h"
#ifdef USE_XPROF_STATS
+#include "profiling.h"
+#if HAVE_ASSERT_H
+#include <assert.h>
+#endif
#if HAVE_GNUMALLLOC_H
#include <gnumalloc.h>
#elif HAVE_MALLOC_H
-
/*
* $Id$
*
#define _etext etext
+/* NP: this file is where the memory allocators are defined. */
+#define SQUID_NO_ALLOC_PROTECT 1
+
#include "config.h"
#include "profiling.h"
SOFTWARE.
******************************************************************/
+#define SQUID_NO_STRING_BUFFER_PROTECT 1
#include "config.h"
#include <stdio.h>
if (ctrlp->operation == _AIO_READ)
squidaio_xfree(ctrlp->bufp, ctrlp->len);
- squidaio_ctrl_pool->free(ctrlp);
+ squidaio_ctrl_pool->freeOne(ctrlp);
}
return retval;
MemAllocator *pool;
if ((pool = squidaio_get_pool(size)) != NULL) {
- pool->free(p);
+ pool->freeOne(p);
} else
xfree(p);
}
int len = strlen(str) + 1;
if ((pool = squidaio_get_pool(len)) != NULL) {
- pool->free(str);
+ pool->freeOne(str);
} else
xfree(str);
}
resultp->aio_errno = requestp->err;
}
- squidaio_request_pool->free(requestp);
+ squidaio_request_pool->freeOne(requestp);
} /* squidaio_cleanup_request */
}
dlinkDelete(m, &used_list);
- DiskThreadsIOStrategy::Instance.squidaio_ctrl_pool->free(ctrlp);
+ DiskThreadsIOStrategy::Instance.squidaio_ctrl_pool->freeOne(ctrlp);
}
}
void
ACLStrategised<MatchType>::operator delete (void *address)
{
- Pool->free(address);
+ Pool->freeOne(address);
}
template <class MatchType>
safe_free(nonce->key);
- digest_nonce_pool->free(nonce);
+ digest_nonce_pool->freeOne(nonce);
}
}
#if HASHED_CBDATA
hash_remove_link(cbdata_htable, &c->hash);
delete c;
- cbdata_index[theType].pool->free((void *)p);
+ cbdata_index[theType].pool->freeOne((void *)p);
#else
c->cbdata::~cbdata();
- cbdata_index[theType].pool->free(c);
+ cbdata_index[theType].pool->freeOne(c);
#endif
return NULL;
}
#if HASHED_CBDATA
hash_remove_link(cbdata_htable, &c->hash);
delete c;
- cbdata_index[theType].pool->free((void *)p);
+ cbdata_index[theType].pool->freeOne((void *)p);
#else
c->cbdata::~cbdata();
- cbdata_index[theType].pool->free(c);
+ cbdata_index[theType].pool->freeOne(c);
#endif
}
-
/*
* $Id$
*
#ifdef USE_POLL
+#if HAVE_POLL_H
+#include <poll.h>
+#endif
+
+/* Needed for poll() on Linux at least */
+#if USE_POLL
+#ifndef POLLRDNORM
+#define POLLRDNORM POLLIN
+#endif
+#ifndef POLLWRNORM
+#define POLLWRNORM POLLOUT
+#endif
+#endif
+
static int MAX_POLL_TIME = 1000; /* see also comm_quick_poll_required() */
#ifndef howmany
if (m == NULL)
return;
- dlink_node_pool->free(m);
+ dlink_node_pool->freeOne(m);
}
void
}
if (srv->data != NULL)
- hlp->datapool->free(srv->data);
+ hlp->datapool->freeOne(srv->data);
cbdataReferenceDone(srv->parent);
static void
htcpFreeDetail(htcpDetail * d)
{
- htcpDetailPool->free(d);
+ htcpDetailPool->freeOne(d);
}
/*
void
memFree(void *p, int type)
{
- MemPools[type]->free(p);
+ MemPools[type]->freeOne(p);
}
/* allocate a variable size buffer using best-fit pool */
memMeterDec(StrCountMeter);
memMeterDel(StrVolumeMeter, size);
- pool ? pool->free(buf) : xfree(buf);
+ pool ? pool->freeOne(buf) : xfree(buf);
}
/* Find the best fit MEM_X_BUF type */
parent->unlinkList(this);
if (nfds_alloc == PCONN_FDS_SZ)
- pconn_fds_pool->free(fds);
+ pconn_fds_pool->freeOne(fds);
else
xfree(fds);
xmemcpy(fds, old, nfds * sizeof(int));
if (nfds == PCONN_FDS_SZ)
- pconn_fds_pool->free(old);
+ pconn_fds_pool->freeOne(old);
else
xfree(old);
}
dlinkDelete(&lru_node->node, &lru->list);
- lru_node_pool->free(lru_node);
+ lru_node_pool->freeOne(lru_node);
lru->count -= 1;
}
goto try_again;
}
- lru_node_pool->free(lru_node);
+ lru_node_pool->freeOne(lru_node);
lru->count -= 1;
lru->setPolicyNode(entry, NULL);
return entry;
#if HAVE_ERRNO_H
#include <errno.h>
#endif
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
#if HAVE_GRP_H
#include <grp.h>
#endif
#ifdef _SQUID_WIN32_
#include <io.h>
#endif
-
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#define NAMLEN(dirent) strlen((dirent)->d_name)
-#else /* HAVE_DIRENT_H */
-#define dirent direct
-#define NAMLEN(dirent) (dirent)->d_namlen
-#if HAVE_SYS_NDIR_H
-#include <sys/ndir.h>
-#endif /* HAVE_SYS_NDIR_H */
-#if HAVE_SYS_DIR_H
-#include <sys/dir.h>
-#endif /* HAVE_SYS_DIR_H */
-#if HAVE_NDIR_H
-#include <ndir.h>
-#endif /* HAVE_NDIR_H */
-#endif /* HAVE_DIRENT_H */
-
-#if defined(__QNX__)
-#include <unix.h>
-#endif
-
#if HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
-
-/*
- * We require poll.h before using poll(). If the symbols used
- * by poll() are defined elsewhere, we will need to make this
- * a more sophisticated test.
- * -- Oskar Pearson <oskar@is.co.za>
- * -- Stewart Forster <slf@connect.com.au>
- */
-#if USE_POLL
-#if HAVE_POLL_H
-#include <poll.h>
-#endif /* HAVE_POLL_H */
-#endif /* USE_POLL */
-
-
-/*
- * Trap unintentional use of fd_set. Must not be used outside the
- * select code as it only supports FD_SETSIZE number of filedescriptors
- * and Squid may be running with a lot more..
- * But only for code linked into Squid, not the helpers.. (unlinkd, pinger)
- */
-#ifdef SQUID_FDSET_NOUSE
-# ifndef SQUID_HELPER
-# define fd_set ERROR_FD_SET_USED
-# endif
-#endif
-
#if HAVE_MATH_H
#include <math.h>
#endif
-#if 0 // moved to include/rfc2181.h - RFC defined constants
-#define SQUIDHOSTNAMELEN 256
-#endif
-
#ifndef MAXPATHLEN
#define MAXPATHLEN SQUID_MAXPATHLEN
#endif
-
-#if !HAVE_STRUCT_RUSAGE
-/*
- * If we don't have getrusage() then we create a fake structure
- * with only the fields Squid cares about. This just makes the
- * source code cleaner, so we don't need lots of #ifdefs in other
- * places
- */
-
-struct rusage {
-
- struct timeval ru_stime;
-
- struct timeval ru_utime;
- int ru_maxrss;
- int ru_majflt;
-};
-
-#endif
-
-#if !defined(HAVE_GETPAGESIZE) && defined(_SQUID_HPUX_)
-#define HAVE_GETPAGESIZE
-#define getpagesize( ) sysconf(_SC_PAGE_SIZE)
-#endif
-
-#if defined(_SQUID_MSWIN_) && !defined(getpagesize)
-/* Windows may lack getpagesize() prototype */
-SQUIDCEXTERN size_t getpagesize(void);
-#endif /* _SQUID_MSWIN_ */
-
-#ifndef SA_RESTART
-#define SA_RESTART 0
-#endif
-#ifndef SA_NODEFER
-#define SA_NODEFER 0
-#endif
-#ifndef SA_RESETHAND
-#define SA_RESETHAND 0
-#endif
-#if SA_RESETHAND == 0 && defined(SA_ONESHOT)
-#undef SA_RESETHAND
-#define SA_RESETHAND SA_ONESHOT
-#endif
-
#if LEAK_CHECK_MODE
#define LOCAL_ARRAY(type,name,size) \
static type *local_##name=NULL; \
#include "ssl_support.h"
#endif
-/* Needed for poll() on Linux at least */
-#if USE_POLL
-#ifndef POLLRDNORM
-#define POLLRDNORM POLLIN
-#endif
-#ifndef POLLWRNORM
-#define POLLWRNORM POLLOUT
-#endif
-#endif
-
#ifdef SQUID_SNMP
#include "cache_snmp.h"
#endif
#include "protos.h"
#include "globals.h"
-/* Exclude CPPUnit tests from the below restriction. */
-/* BSD implementation uses these still */
-#if !defined(SQUID_UNIT_TEST)
-/*
- * Squid source files should not call these functions directly.
- * Use xmalloc, xfree, xcalloc, snprintf, and xstrdup instead.
- * Also use xmemcpy, xisspace, ...
- */
-#ifndef malloc
-#define malloc +
-#endif
-template <class V>
-void free(V x) { fatal("Do not use ::free()"); }
-#ifndef calloc
-#define calloc +
-#endif
-#ifndef sprintf
-#define sprintf +
-#endif
-#ifndef strdup
-#define strdup +
-#endif
-#endif /* !SQUID_UNIT_TEST */
-
-/*
- * Hey dummy, don't be tempted to move this to lib/config.h.in
- * again. O_NONBLOCK will not be defined there because you didn't
- * #include <fcntl.h> yet.
- */
-#if defined(_SQUID_SUNOS_)
-/*
- * We assume O_NONBLOCK is broken, or does not exist, on SunOS.
- */
-#define SQUID_NONBLOCK O_NDELAY
-#elif defined(O_NONBLOCK)
-/*
-* We used to assume O_NONBLOCK was broken on Solaris, but evidence
-* now indicates that its fine on Solaris 8, and in fact required for
-* properly detecting EOF on FIFOs. So now we assume that if
-* its defined, it works correctly on all operating systems.
-*/
-#define SQUID_NONBLOCK O_NONBLOCK
-/*
-* O_NDELAY is our fallback.
-*/
-#else
-#define SQUID_NONBLOCK O_NDELAY
-#endif
-
/*
* I'm sick of having to keep doing this ..
*/
void
StoreEntry::operator delete (void *address)
{
- pool->free(address);
+ pool->freeOne(address);
}
void
assert (something);
assert (something->aValue == 0);
something->aValue = 5;
- Pool->free(something);
+ Pool->freeOne(something);
SomethingToAlloc *otherthing = static_cast<SomethingToAlloc *>(Pool->alloc());
assert (otherthing == something);
assert (otherthing->aValue == 0);
- Pool->free (otherthing);
+ Pool->freeOne(otherthing);
delete Pool;
}
if (m == NULL)
return;
- dlink_node_pool->free(m);
+ dlink_node_pool->freeOne(m);
}
void
if (newhost) {
char *t;
newhost += 3;
- newhost = strdup(newhost);
+ newhost = xstrdup(newhost);
t = newhost + strcspn(newhost, "@/?");
if (*t == '@') {
newhost = t + 1;