/*
- * $Id: Stack.h,v 1.12 2002/10/13 20:34:51 robertc Exp $
+ * $Id: Stack.h,v 1.13 2003/01/22 10:05:42 robertc Exp $
*
* AUTHOR: Alex Rousskov
*
#define stackInit arrayInit
#define stackClean arrayClean
#define stackDestroy arrayDestroy
-SQUIDCEXTERN void *stackPop(Stack * s);
#define stackPush arrayAppend
#define stackPrePush arrayPreAppend
-SQUIDCEXTERN void *stackTop(Stack * s);
+template <class S>
+typename S::value_type
+stackPop(S * s)
+{
+ assert(s);
+ if (!s->count)
+ return typename S::value_type();
+ typename S::value_type result = s->items[--s->count];
+ s->items[s->count] = typename S::value_type();
+ return result;
+}
+
+/* todo, fatal on empty Top call */
+template <class S>
+typename S::value_type
+stackTop(S * s)
+{
+ assert(s);
+ return s->count ? s->items[s->count - 1] : typename S::value_type();
+}
#endif /* SQUID_STACK_H */
## Process this file with automake to produce Makefile.in
#
-# $Id: Makefile.am,v 1.6 2003/01/18 14:06:32 robertc Exp $
+# $Id: Makefile.am,v 1.7 2003/01/22 10:05:41 robertc Exp $
#
if ENABLE_XPROF_STATS
safe_inet_addr.c \
$(SNPRINTFSOURCE) \
splay.c \
- Stack.c \
stub_memaccount.c \
util.c \
uudecode.c \
+++ /dev/null
-/*
- * $Id: Stack.c,v 1.11 2001/01/12 00:37:12 wessels Exp $
- *
- * AUTHOR: Alex Rousskov
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
- *
- */
-
-/*
- * Stack is a (void*) stack with unlimited capacity; based on Array
- */
-
-
-#include "config.h"
-#if HAVE_ASSERT_H
-#include <assert.h>
-#endif
-#if HAVE_STRING_H
-#include <string.h>
-#endif
-#include "util.h"
-#include "Stack.h"
-
-
-void *
-stackPop(Stack * s)
-{
- assert(s);
- return s->count ? s->items[--s->count] : NULL;
-}
-
-void *
-stackTop(Stack * s)
-{
- assert(s);
- return s->count ? s->items[s->count - 1] : NULL;
-}
/*
- * $Id: HttpHdrRange.cc,v 1.28 2002/10/15 08:03:29 robertc Exp $
+ * $Id: HttpHdrRange.cc,v 1.29 2003/01/22 10:05:43 robertc Exp $
*
* DEBUG: section 64 HTTP Range Header
* AUTHOR: Alex Rousskov
httpHdrRangeDup(const HttpHdrRange * range)
{
HttpHdrRange *dup;
- int i;
+ size_t i;
assert(range);
dup = httpHdrRangeCreate();
stackPrePush(&dup->specs, range->specs.count);
int
httpHdrRangeCanonize(HttpHdrRange * range, ssize_t clen)
{
- int i;
+ size_t i;
HttpHdrRangeSpec *spec;
HttpHdrRangePos pos = HttpHdrRangeInitPos;
Stack goods;
httpHdrRangeGetSpec(const HttpHdrRange * range, HttpHdrRangePos * pos)
{
assert(range);
- assert(pos && *pos >= -1 && *pos < range->specs.count);
+ assert(pos && *pos >= -1 && *pos < (ssize_t)range->specs.count);
(*pos)++;
- if (*pos < range->specs.count)
+ if (*pos < (ssize_t)range->specs.count)
return (HttpHdrRangeSpec *) range->specs.items[*pos];
else
return NULL;
/*
- * $Id: HttpHeader.cc,v 1.82 2002/12/06 23:19:13 hno Exp $
+ * $Id: HttpHeader.cc,v 1.83 2003/01/22 10:05:43 robertc Exp $
*
* DEBUG: section 55 HTTP Header
* AUTHOR: Alex Rousskov
httpHeaderGetEntry(const HttpHeader * hdr, HttpHeaderPos * pos)
{
assert(hdr && pos);
- assert(*pos >= HttpHeaderInitPos && *pos < hdr->entries.count);
- for ((*pos)++; *pos < hdr->entries.count; (*pos)++) {
+ assert(*pos >= HttpHeaderInitPos && *pos < (ssize_t)hdr->entries.count);
+ for ((*pos)++; *pos < (ssize_t)hdr->entries.count; (*pos)++) {
if (hdr->entries.items[*pos])
return (HttpHeaderEntry*)hdr->entries.items[*pos];
}
httpHeaderDelAt(HttpHeader * hdr, HttpHeaderPos pos)
{
HttpHeaderEntry *e;
- assert(pos >= HttpHeaderInitPos && pos < hdr->entries.count);
+ assert(pos >= HttpHeaderInitPos && pos < (ssize_t)hdr->entries.count);
e = (HttpHeaderEntry*)hdr->entries.items[pos];
hdr->entries.items[pos] = NULL;
/* decrement header length, allow for ": " and crlf */
/*
- * $Id: cbdata.cc,v 1.49 2002/10/25 03:13:51 robertc Exp $
+ * $Id: cbdata.cc,v 1.50 2003/01/22 10:05:43 robertc Exp $
*
* DEBUG: section 45 Callback Data Registry
* ORIGINAL AUTHOR: Duane Wessels
template <class T>
T& for_each(Stack const &collection, T& visitor)
{
- for (int index = 0; index < collection.count; ++index)
+ for (size_t index = 0; index < collection.count; ++index)
visitor(*(typename T::argument_type const *)collection.items[index]);
return visitor;
};
/*
- * $Id: errorpage.cc,v 1.180 2002/10/25 07:36:32 robertc Exp $
+ * $Id: errorpage.cc,v 1.181 2003/01/22 10:05:43 robertc Exp $
*
* DEBUG: section 4 Error Generation
* AUTHOR: Duane Wessels
if (strcmp(err_type_str[i], page_name) == 0)
return i;
}
- for (i = 0; i < ErrorDynamicPages.count; i++) {
- if (strcmp(((ErrorDynamicPageInfo *) ErrorDynamicPages.items[i])->page_name, page_name) == 0)
- return i + ERR_MAX;
+ for (size_t in = 0; in < ErrorDynamicPages.count; in++) {
+ if (strcmp(((ErrorDynamicPageInfo *) ErrorDynamicPages.items[in])->page_name, page_name) == 0)
+ return in + ERR_MAX;
}
return ERR_NONE;
}
{
if (pageId >= ERR_NONE && pageId < ERR_MAX) /* common case */
return err_type_str[pageId];
- if (pageId >= ERR_MAX && pageId - ERR_MAX < ErrorDynamicPages.count)
+ if (pageId >= ERR_MAX && pageId - ERR_MAX < (ssize_t)ErrorDynamicPages.count)
return ((ErrorDynamicPageInfo *) ErrorDynamicPages.
items[pageId - ERR_MAX])->page_name;
return "ERR_UNKNOWN"; /* should not happen */