Incorrect change in cache_cf.c

From: David Luyer <david@dont-contact.us>
Date: Wed, 16 Oct 2002 20:31:00 +1000

--- squid/src/cache_cf.c:1.396.2.7 Sat Sep 7 09:13:59 2002
+++ squid/src/cache_cf.c Mon Oct 14 02:18:27 2002
@@ -828,7 +830,7 @@
        delayFreeDelayPool(pool);
        safe_free(cfg->rates[pool]);
     }
- cfg->rates[pool] = xmalloc(class * sizeof(delaySpec));
+ cfg->rates[pool] = xmalloc(class * sizeof(delaySpecSet));
     cfg->class[pool] = class;
     cfg->rates[pool]->aggregate.restore_bps =
cfg->rates[pool]->aggregate.max_bytes = -1;
     if (cfg->class[pool] >= 3)

This change is wrong.

It should be fine as it was before (class * sizeof(delaySpec)) but
if someone really insists on changing it, it should be changed
to (sizeof(delaySpecSet)) without the multiplier and the relevent
comments updated (delay_pools.c, structs.h, etc).

See this comment in structs.h for more clarity:

(structs.h... missing closing bracket on this comment)
/* malloc()'d only as far as used (class * sizeof(delaySpec)!
 * order of elements very important!
 */
struct _delaySpecSet {
    delaySpec aggregate;
    delaySpec individual;
    delaySpec network;
};

(delay_pools.c - this and similar comments contained many times)
    /* delaySetSpec may be pointer to partial structure so MUST pass by
     * reference.
     */

aggregate is class 1 and has only the first delaySpec completed.
individual is class 2 and has the two delaySpecs completed.
network is class 3 and has all three delaySpecs.

This is _always_ passed by reference, and is only malloc()d as much
memory as is required for the elements it contains. It's the same as
the union delayPool which is malloc()d only for the current structure
it contains.

David.

--
David Luyer                                     Phone:   +61 3 9674 7525
Network Development Manager    P A C I F I C    Fax:     +61 3 9699 8693
Pacific Internet (Australia)  I N T E R N E T   Mobile:  +61 4 1111 BYTE
http://www.pacific.net.au/                      NASDAQ:  PCNTF
Received on Wed Oct 16 2002 - 04:31:03 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:16:56 MST