Thanks for the pointers (no pun intended).
It's because the linked structures actually represent polynomials. What I'm trying to do is relink those structures so that:
1. The coefficients are reduced modulo p
2. There are only terms with non-zero coefficients
3. No two terms have the same power (no repetition of power)
So when I, for example, see that the coefficient of a term reduces to 0 modulo p, I might as well just free the memory that it occupies because I don't need it. Thanks for the suggestion though, I'll try putting printf() statements to see what I get.
I see. But what I've done is this:
struct term *p = malloc(n*sizeof(struct term)).
Doing something like
free(p + 1);
doesn't change that I can still access p, p + 2, ... , p + n - 1, right?