Commit 2e662324 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make iterator deal correctly with end of list.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4851 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent f8852b91
......@@ -66,7 +66,7 @@ void *VSL_Find_Alloc(struct VSL_data *vd, const char *class, const char *type,
const char *ident, unsigned *lenp);
struct shmalloc *vsl_iter0(struct VSL_data *vd);
struct shmalloc *vsl_itern(struct VSL_data *vd, struct shmalloc **pp);
void vsl_itern(struct VSL_data *vd, struct shmalloc **pp);
#define VSL_FOREACH(var, vd) \
for((var) = vsl_iter0((vd)); (var) != NULL; vsl_itern((vd), &(var)))
......
......@@ -177,19 +177,22 @@ vsl_iter0(struct VSL_data *vd)
return (&vd->vsl_lh->head);
}
struct shmalloc *
void
vsl_itern(struct VSL_data *vd, struct shmalloc **pp)
{
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
if (vd->alloc_seq != vd->vsl_lh->alloc_seq)
return(NULL);
if (vd->alloc_seq != vd->vsl_lh->alloc_seq) {
*pp = NULL;
return;
}
CHECK_OBJ_NOTNULL(*pp, SHMALLOC_MAGIC);
*pp = SHA_NEXT(*pp);
if ((void*)*pp >= vd->vsl_end)
return (NULL);
if ((void*)(*pp) >= vd->vsl_end) {
*pp = NULL;
return;
}
CHECK_OBJ_NOTNULL(*pp, SHMALLOC_MAGIC);
return (*pp);
}
/*--------------------------------------------------------------------*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment