kohler/click — Issue #39: Weird memset argument in RangeIPLookup::flush_table()
Author: pallas
Created: 2012-01-11 21:42:31+00:00
State: open

In elements/ip/rangeiplookup.cc, it says

```C++
void
RangeIPLookup::flush_table()
{
_helper.flush();
memset(_range_base, 0, sizeof(_range_base));
memset(_range_len, 0, sizeof(_range_len));
memset(_range_t, 0, sizeof(_range_t));
}
```

Since those members are pointers, memset is clearing something the size of the pointer, not an element in the underlying array. Is this the intention? or should the code be

```C++
void
RangeIPLookup::flush_table()
{
_helper.flush();
memset(_range_base, 0, sizeof(*_range_base));
memset(_range_len, 0, sizeof(*_range_len));
memset(_range_t, 0, sizeof(*_range_t));
}
```
or

```C++
void
RangeIPLookup::flush_table()
{
_helper.flush();
memset(_range_base, 0, (1 << KICKSTART_BITS) * sizeof(*_range_base));
memset(_range_len, 0, (1 << KICKSTART_BITS) * sizeof(*_range_len));
memset(_range_t, 0, RANGES_MAX * sizeof(*_range_t));
}
```