Commit 90f60f8e authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Make expire_sources run in linear time.

It's not like it's run that often, but I've got OCD.
parent bb2114ca
......@@ -201,7 +201,7 @@ update_source(struct source *src,
void
expire_sources()
{
int i = 0;
int i = 0, j = 0;
while(i < source_slots) {
struct source *src = sources[i];
......@@ -211,14 +211,18 @@ expire_sources()
if(src->route_count == 0 && src->time < now.tv_sec - SOURCE_GC_TIME) {
free(src);
memmove(sources + i, sources + i + 1,
(source_slots - i - 1) * sizeof(struct source*));
sources[source_slots - 1] = NULL;
source_slots--;
sources[i] = NULL;
i++;
} else {
if(j < i) {
sources[j] = sources[i];
sources[i] = NULL;
}
i++;
j++;
}
}
source_slots = j;
}
void
......
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