--------------------- PatchSet 10405 Date: 2008/01/14 15:02:50 Author: adri Branch: s27_adri Tag: (none) Log: Make the string buffer regions immutable. Getting this stuff right is going to be very important for the "consume" operator. Members: libbuf/String.c:1.1.2.21->1.1.2.22 libbuf/buf.c:1.1.2.11->1.1.2.12 Index: squid/libbuf/String.c =================================================================== RCS file: /cvsroot/squid-sf//squid/libbuf/Attic/String.c,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.c 6 Jan 2008 11:38:29 -0000 1.1.2.21 +++ squid/libbuf/String.c 14 Jan 2008 15:02:50 -0000 1.1.2.22 @@ -1,6 +1,6 @@ /* - * $Id: String.c,v 1.1.2.21 2008/01/06 11:38:29 adri Exp $ + * $Id: String.c,v 1.1.2.22 2008/01/14 15:02:50 adri Exp $ * * DEBUG: section 67 String * AUTHOR: Duane Wessels @@ -88,6 +88,7 @@ assert(s && str); stringInitBuf(s, len + 1); buf_append(s->nb, str, len, BF_NONE); + buf_make_immutable(s->nb, -1); //printf("len: %d, buflen: %d, size %d\n", len, buf_len(s->nb), s->nb->size); stringStats.create++; s->len = len; @@ -142,6 +143,7 @@ stringMakePrivate(s); buf_append(s->nb, str, len, BF_APPEND_NUL); + buf_make_immutable(s->nb, -1); s->len += len; } @@ -162,6 +164,7 @@ nb = buf_create_size(strLen(*s)); buf_append(nb, strBuf(*s), strLen(*s), BF_APPEND_NUL); + buf_make_immutable(nb, -1); 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; @@ -282,6 +285,7 @@ assert(offset < s.len); stringMakePrivate(&s); a = buf_put_chr(s.nb, offset, ch); + buf_make_immutable(s.nb, -1); assert(a); } @@ -295,6 +299,7 @@ /* XXX this is breaking buf_t layering; please revisit! */ s.len = s.nb->len = pos; a = buf_put_chr(s.nb, pos, '\0'); + buf_make_immutable(s.nb, -1); assert(a); } Index: squid/libbuf/buf.c =================================================================== RCS file: /cvsroot/squid-sf//squid/libbuf/Attic/buf.c,v retrieving revision 1.1.2.11 retrieving revision 1.1.2.12 diff -u -r1.1.2.11 -r1.1.2.12 --- squid/libbuf/buf.c 13 Jan 2008 15:42:20 -0000 1.1.2.11 +++ squid/libbuf/buf.c 14 Jan 2008 15:02:50 -0000 1.1.2.12 @@ -218,6 +218,8 @@ int buf_make_immutable(buf_t *buf, int newofs) { + if (newofs == -1) + newofs = buf->len; if (newofs < buf->sofs) { debug(85, 5) ("buf_make_immutable: %p: already seen %d bytes as immutable!!\n", buf, newofs); return 1; @@ -226,3 +228,9 @@ buf->sofs = newofs; return 1; } + +void +buf_consume(buf_t *buf, int numbytes) +{ + +}