Consider the following innocuous-looking code:
pan_merge(packed, vtx->attributes[i], ATTRIBUTE);
Under the current implementation, this code is completely broken. Why? The current implemention is a macro which hardcodes the loop index i, which shadows the i used to index attributes. Pull out a helper method so we do the right thing without resulting to further preprocessor abuse (COUNTER).
While making things more robust, assert the crucial pan_merge invariant that the total size is a multiple of 4; if this fails, the routine risks memory corruption.
Signed-off-by: Alyssa Rosenzweig email@example.com