if (old)
{
ch->counters[old->generation]--;
- if (old->generation < ch->max_generation)
+ if (old->generation <= ch->max_generation)
{
changed = 1;
ch->counters[COUNTER]--;
if (new)
{
ch->counters[new->generation]++;
- if (new->generation < ch->max_generation)
+ if (new->generation <= ch->max_generation)
{
changed = 1;
ch->counters[COUNTER]++;
/* recalculate sum */
sc->counters[COUNTER] = 0;
- for (u8 i = 0; i < sc->max_generation; i++)
+ for (u8 i = 0; i <= sc->max_generation; i++)
sc->counters[COUNTER] += sc->counters[i];
sc->sum = sc->counters[COUNTER];