--------------------- PatchSet 11745 Date: 2007/11/19 12:11:50 Author: adrian Branch: HEAD Tag: (none) Log: Author: Adrian Chadd Implement an arrayShrink() which simply resets a.count to the given value Members: include/Array.h:1.7->1.8 lib/Array.c:1.8->1.9 Index: squid/include/Array.h =================================================================== RCS file: /cvsroot/squid/squid/include/Array.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- squid/include/Array.h 23 Oct 2005 15:20:49 -0000 1.7 +++ squid/include/Array.h 19 Nov 2007 12:11:50 -0000 1.8 @@ -1,5 +1,5 @@ /* - * $Id: Array.h,v 1.7 2005/10/23 15:20:49 hno Exp $ + * $Id: Array.h,v 1.8 2007/11/19 12:11:50 adrian Exp $ * * AUTHOR: Alex Rousskov * @@ -50,6 +50,8 @@ extern void arrayAppend(Array * s, void *obj); extern void arrayInsert(Array * s, void *obj, int position); extern void arrayPreAppend(Array * s, int app_count); +extern void arrayShrink(Array *a, int new_count); + #endif /* SQUID_ARRAY_H */ Index: squid/lib/Array.c =================================================================== RCS file: /cvsroot/squid/squid/lib/Array.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- squid/lib/Array.c 23 Oct 2005 15:20:49 -0000 1.8 +++ squid/lib/Array.c 19 Nov 2007 12:11:50 -0000 1.9 @@ -1,5 +1,5 @@ /* - * $Id: Array.c,v 1.8 2005/10/23 15:20:49 hno Exp $ + * $Id: Array.c,v 1.9 2007/11/19 12:11:50 adrian Exp $ * * AUTHOR: Alex Rousskov * @@ -138,3 +138,11 @@ /* reset, just in case */ memset(a->items + a->count, 0, (a->capacity - a->count) * sizeof(void *)); } + +void +arrayShrink(Array *a, int new_count) +{ + assert(new_count < a->capacity); + assert(new_count >= 0); + a->count = new_count; +}