Recall the sqrt(triangles) example. The c_ function must compute the change statistic for the number of triangles due to the proposed toggle. If this toggle is then accepted, the u_ function must repeat this calculation to update the stored number of triangles. This is both code duplication and waste of computing time.
A simple API change would be to create a new container element on the ModelTerm struct, e.g.,
struct {
Vertex i, j;
void *payload;
}
that the c_ function is allowed to write to, recording the toggle information and whatever data structure the c_ function wants to pass along.
Then the u_ function must check that it's the same toggle, use the information, then set i and j to 0 so that on the off chance that it is called again without a c_ call in between, it'll know that the information is not valid.
The f_ function, as in case of the other storage, can free the payload if not NULL and then free the struct.