--------------------- PatchSet 10357 Date: 2008/01/03 09:32:20 Author: adri Branch: s27_adri Tag: (none) Log: Move around the buffer creation and memnode creation code so stmemAppendRef() is called during stmemAppend(). Members: src/stmem.c:1.10.2.4.4.7->1.10.2.4.4.8 Index: squid/src/stmem.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/stmem.c,v retrieving revision 1.10.2.4.4.7 retrieving revision 1.10.2.4.4.8 diff -u -r1.10.2.4.4.7 -r1.10.2.4.4.8 --- squid/src/stmem.c 2 Jan 2008 17:29:33 -0000 1.10.2.4.4.7 +++ squid/src/stmem.c 3 Jan 2008 09:32:20 -0000 1.10.2.4.4.8 @@ -1,6 +1,6 @@ /* - * $Id: stmem.c,v 1.10.2.4.4.7 2008/01/02 17:29:33 adri Exp $ + * $Id: stmem.c,v 1.10.2.4.4.8 2008/01/03 09:32:20 adri Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Harvest Derived @@ -91,6 +91,22 @@ void stmemAppendRef(mem_hdr *mem, buf_t *buf, int offset, int len) { + mem_node *p; + + debug(19, 6) ("memAppendRef: %p: len %d\n", mem, len); + p = memAllocate(MEM_MEM_NODE); /* This is a non-zero'ed buffer; make sure you fully initialise it */ + p->next = NULL; + p->uses = 0; + store_mem_size += buf_capacity(buf); + bufregion_init_buf(&p->br, buf, offset, len); + if (!mem->head) { + /* The chain is empty */ + mem->head = mem->tail = p; + } else { + /* Append it to existing chain */ + mem->tail->next = p; + mem->tail = p; + } } /* Append incoming data. */ @@ -107,7 +123,6 @@ void stmemAppend(mem_hdr * mem, const char *data, int len) { - mem_node *p; buf_t *b; debug(19, 6) ("memAppend: len %d\n", len); @@ -121,23 +136,10 @@ * matches the end of the used buffer, copy into the buffer and grow the reference. * Else create a new buffer. */ - - p = memAllocate(MEM_MEM_NODE); /* This is a non-zero'ed buffer; make sure you fully initialise it */ - p->next = NULL; - p->uses = 0; - b = buf_create_size(len); - buf_append(b, data, len, BF_NONE); - store_mem_size += buf_capacity(b); - bufregion_init_buf(&p->br, b, 0, len); - b = buf_deref(b); - if (!mem->head) { - /* The chain is empty */ - mem->head = mem->tail = p; - } else { - /* Append it to existing chain */ - mem->tail->next = p; - mem->tail = p; - } + b = buf_create_size(len); + buf_append(b, data, len, BF_NONE); + stmemAppendRef(mem, b, 0, len); + b = buf_deref(b); } /*