--------------------- PatchSet 10369 Date: 2008/01/05 11:45:17 Author: adri Branch: s27_adri Tag: (none) Log: Start fleshing out the "offset" for strings in a buffer. Members: libbuf/String.c:1.1.2.17->1.1.2.18 libbuf/String.h:1.1.2.21->1.1.2.22 Index: squid/libbuf/String.c =================================================================== RCS file: /cvsroot/squid-sf//squid/libbuf/Attic/String.c,v retrieving revision 1.1.2.17 retrieving revision 1.1.2.18 diff -u -r1.1.2.17 -r1.1.2.18 --- squid/libbuf/String.c 28 Dec 2007 07:50:21 -0000 1.1.2.17 +++ squid/libbuf/String.c 5 Jan 2008 11:45:17 -0000 1.1.2.18 @@ -1,6 +1,6 @@ /* - * $Id: String.c,v 1.1.2.17 2007/12/28 07:50:21 adri Exp $ + * $Id: String.c,v 1.1.2.18 2008/01/05 11:45:17 adri Exp $ * * DEBUG: section 67 String * AUTHOR: Duane Wessels @@ -49,7 +49,7 @@ #include "buf.h" #include "String.h" -const String StringNull = { 0, NULL }; +const String StringNull = { 0, 0, NULL }; stringStatsStruct stringStats = { 0, 0, 0, 0, 0 }; @@ -91,6 +91,7 @@ //printf("len: %d, buflen: %d, size %d\n", len, buf_len(s->nb), s->nb->size); stringStats.create++; s->len = len; + s->offset = 0; s->nb->create.file = file; s->nb->create.line = line; } @@ -105,6 +106,7 @@ return StringNull; dup.len = s->len; dup.nb = buf_ref(s->nb); + dup.offset = s->offset; return dup; } @@ -158,10 +160,11 @@ /* If the reference count is >1 then we create a duplicate and deref the old one */ assert(buf_refcnt(s->nb) > 1); - nb = buf_create_size(buf_len(s->nb)); - buf_append(nb, buf_buf(s->nb), buf_len(s->nb), BF_APPEND_NUL); + nb = buf_create_size(strLen(*s)); + buf_append(nb, strBuf(*s), strLen(*s), BF_APPEND_NUL); s->nb = buf_deref(s->nb); s->nb = nb; /* no need to ref it, its already created with the ref intended for us */ + s->offset = 0; } int Index: squid/libbuf/String.h =================================================================== RCS file: /cvsroot/squid-sf//squid/libbuf/Attic/String.h,v retrieving revision 1.1.2.21 retrieving revision 1.1.2.22 diff -u -r1.1.2.21 -r1.1.2.22 --- squid/libbuf/String.h 28 Dec 2007 07:50:22 -0000 1.1.2.21 +++ squid/libbuf/String.h 5 Jan 2008 11:45:17 -0000 1.1.2.22 @@ -4,6 +4,7 @@ struct _String { /* never reference these directly! */ + int offset; /* offset from beginning of buffer */ unsigned short int len; /* current length of our string */ buf_t *nb; /* the backing buffer */ }; @@ -20,7 +21,7 @@ { if (s.nb == NULL) return NULL; - return buf_buf(s.nb); + return buf_buf(s.nb) + s.offset; } #define strBuf(s) strBuf2(s)