--------------------- PatchSet 429 Date: 2002/12/20 07:20:47 Author: rbcollins Branch: esi Tag: (none) Log: extract method Members: src/ESISegment.cc:1.1.2.3->1.1.2.4 src/ESISegment.h:1.1.2.3->1.1.2.4 Index: squid3/src/ESISegment.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESISegment.cc,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- squid3/src/ESISegment.cc 20 Dec 2002 07:12:53 -0000 1.1.2.3 +++ squid3/src/ESISegment.cc 20 Dec 2002 07:20:47 -0000 1.1.2.4 @@ -1,6 +1,6 @@ /* - * $Id: ESISegment.cc,v 1.1.2.3 2002/12/20 07:12:53 rbcollins Exp $ + * $Id: ESISegment.cc,v 1.1.2.4 2002/12/20 07:20:47 rbcollins Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -97,18 +97,12 @@ output=output->next; /* copy the string to output */ while (pos < len) { - size_t amount; if (output->len == sizeof (output->buf)) { assert (output->next == NULL); output->next = new ESISegment; output = output->next; } - amount = len - pos; - if (amount > sizeof (output->buf) - output->len) - amount = sizeof (output->buf) - output->len; - xmemcpy (&output->buf[output->len], s + pos, amount); - output->len += amount; - pos += amount; + pos += output->append(s + pos, len - pos); } } @@ -142,3 +136,14 @@ result->next = next ? next->clone() : NULL; return result; } + +size_t +ESISegment::append(char const *appendBuffer, size_t appendLength) +{ + size_t toCopy = appendLength; + if (toCopy > sizeof (buf) - len) + toCopy = sizeof (buf) - len; + xmemcpy (&buf[len], appendBuffer, toCopy); + len += toCopy; + return toCopy; +} Index: squid3/src/ESISegment.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESISegment.h,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- squid3/src/ESISegment.h 20 Dec 2002 07:12:53 -0000 1.1.2.3 +++ squid3/src/ESISegment.h 20 Dec 2002 07:20:47 -0000 1.1.2.4 @@ -1,5 +1,5 @@ /* - * $Id: ESISegment.h,v 1.1.2.3 2002/12/20 07:12:53 rbcollins Exp $ + * $Id: ESISegment.h,v 1.1.2.4 2002/12/20 07:20:47 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -48,6 +48,7 @@ char buf[HTTP_REQBUF_SZ]; size_t len; /* how much data has been pushed into this */ ESISegment *next; + size_t append(char const *, size_t); }; extern void ESISegmentFreeList (ESISegment **head);