From: Pavel Charvat Date: Wed, 2 Jan 2008 14:54:58 +0000 (+0100) Subject: Bugfix in cycle detector. X-Git-Tag: holmes-import~476^2 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=36ecef4f9eda80fc9ae91e6a0a6e74a090a0b680;p=libucw.git Bugfix in cycle detector. --- diff --git a/lib/url.c b/lib/url.c index 3a3d8c21..ecc18b00 100644 --- a/lib/url.c +++ b/lib/url.c @@ -707,7 +707,7 @@ int url_has_repeated_component(const byte *url) { struct component *comp, **hash; - uns comps, comp_len, rep_prefix; + uns comps, comp_len, rep_prefix, hash_size; const byte *c; uns i, j; @@ -737,13 +737,15 @@ url_has_repeated_component(const byte *url) comp[i].hash = hashf(comp[i].start, comp[i].length); if (comps > url_max_occurences) { - hash = alloca(comps * sizeof(*hash)); - bzero(hash, comps * sizeof(*hash)); + hash_size = next_table_prime(comps * 2); + hash = alloca(hash_size * sizeof(*hash)); + bzero(hash, hash_size * sizeof(*hash)); for (i=0; istart, comp[i].start, comp[i].length)) - j = (j + 1) % comps; + if (++j == hash_size) + j = 0; if (!hash[j]) { hash[j] = &comp[i];