Asymmetric Bounds
#define MAX_ADS 5
struct dr { /* accumulated advertisements */
[...]
n_long dr_pref; /* preference adjusted by metric */
} *cur_drp, drs[MAX_ADS];
[...]
struct dr *drp;
[...]
for (drp = drs; drp < &drs[MAX_ADS]; drp++) {
drp->dr_recv_pref = 0;
drp->dr_life = 0;
}
In the code above drs (the lower bound) is the first element of the array;
drs[MAX_ADS] (the upper bound) the first element outside the array.
When using asymmetric bounds:
- Number of elements is equal to the difference between upper and lower bound.
- When upper bound equals lower bound the range is empty.
- The lower bound is the first occupied element.
- The upper bound is the first free element.