--------------------- PatchSet 10210 Date: 2007/12/12 09:07:52 Author: adri Branch: s27_adri Tag: (none) Log: Remove a strBuf() in the header code, add strCaseCmpStr() to compare two strings * change httpHeaderDelByName() to take a String instead of const char *; eliminate strBuf() call * add strCaseCompStr() to compare two Strings Members: libbuf/String.h:1.1.2.7->1.1.2.8 src/HttpHeader.c:1.28.6.1.4.6->1.28.6.1.4.7 src/protos.h:1.146.2.4.4.7->1.146.2.4.4.8 Index: squid/libbuf/String.h =================================================================== RCS file: /cvsroot/squid-sf//squid/libbuf/Attic/String.h,v retrieving revision 1.1.2.7 retrieving revision 1.1.2.8 diff -u -r1.1.2.7 -r1.1.2.8 --- squid/libbuf/String.h 10 Dec 2007 18:48:45 -0000 1.1.2.7 +++ squid/libbuf/String.h 12 Dec 2007 09:07:52 -0000 1.1.2.8 @@ -46,6 +46,8 @@ #define strCaseCmp(s,str) strcasecmp(strBuf(s), (str)) #define strNCaseCmp(s,str,n) strncasecmp(strBuf(s), (str), (n)) +#define strCaseCmpStr(s1, s2) strncasecmp(strBuf2(s1), strBuf2(s2), XMIN(strLen2(s1), strLen2(s2))) + /* XXX this should eventually take the String length + offset under consideration! */ #define strNCaseCmpOffset(s, o, str, n) strncasecmp(strBuf(s) + (o), (str), (n)) Index: squid/src/HttpHeader.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpHeader.c,v retrieving revision 1.28.6.1.4.6 retrieving revision 1.28.6.1.4.7 diff -u -r1.28.6.1.4.6 -r1.28.6.1.4.7 --- squid/src/HttpHeader.c 12 Dec 2007 08:59:27 -0000 1.28.6.1.4.6 +++ squid/src/HttpHeader.c 12 Dec 2007 09:07:52 -0000 1.28.6.1.4.7 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.c,v 1.28.6.1.4.6 2007/12/12 08:59:27 adri Exp $ + * $Id: HttpHeader.c,v 1.28.6.1.4.7 2007/12/12 09:07:52 adri Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -420,7 +420,7 @@ if (e->id != HDR_OTHER) httpHeaderDelById(old, e->id); else - httpHeaderDelByName(old, strBuf(e->name)); + httpHeaderDelByName(old, e->name); } pos = HttpHeaderInitPos; while ((e = httpHeaderGetEntry(fresh, &pos))) { @@ -652,15 +652,15 @@ * deletes all fields with a given name if any, returns #fields deleted; */ int -httpHeaderDelByName(HttpHeader * hdr, const char *name) +httpHeaderDelByName(HttpHeader * hdr, String name) { int count = 0; HttpHeaderPos pos = HttpHeaderInitPos; HttpHeaderEntry *e; httpHeaderMaskInit(&hdr->mask, 0); /* temporal inconsistency */ - debug(55, 7) ("deleting '%s' fields in hdr %p\n", name, hdr); + debug(55, 7) ("deleting '%.*s' fields in hdr %p\n", strLen2(name), strBuf2(name), hdr); while ((e = httpHeaderGetEntry(hdr, &pos))) { - if (!strCaseCmp(e->name, name)) { + if (!strCaseCmpStr(e->name, name)) { httpHeaderDelAt(hdr, pos); count++; } else Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.146.2.4.4.7 retrieving revision 1.146.2.4.4.8 diff -u -r1.146.2.4.4.7 -r1.146.2.4.4.8 --- squid/src/protos.h 12 Dec 2007 08:04:12 -0000 1.146.2.4.4.7 +++ squid/src/protos.h 12 Dec 2007 09:07:52 -0000 1.146.2.4.4.8 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.146.2.4.4.7 2007/12/12 08:04:12 adri Exp $ + * $Id: protos.h,v 1.146.2.4.4.8 2007/12/12 09:07:52 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -451,7 +451,7 @@ extern String httpHeaderGetByName(const HttpHeader * hdr, const char *name); extern String httpHeaderGetListMember(const HttpHeader * hdr, http_hdr_type id, const char *member, const char separator); extern String httpHeaderGetByNameListMember(const HttpHeader * hdr, const char *name, const char *member, const char separator); -extern int httpHeaderDelByName(HttpHeader * hdr, const char *name); +extern int httpHeaderDelByName(HttpHeader * hdr, String name); extern int httpHeaderDelById(HttpHeader * hdr, http_hdr_type id); extern void httpHeaderDelAt(HttpHeader * hdr, HttpHeaderPos pos); extern void httpHeaderRefreshMask(HttpHeader * hdr);