{
const GLuint oldNum = paramList->NumParameters;
const unsigned oldValNum = paramList->NumParameterValues;
+ const unsigned needSizeValues = oldValNum + reserve_values * 4;
if (paramList->DisallowRealloc &&
(oldNum + reserve_params > paramList->Size ||
- oldValNum + reserve_values > paramList->SizeValues)) {
+ needSizeValues > paramList->SizeValues)) {
_mesa_problem(NULL, "Parameter storage reallocation disallowed. This "
"is a Mesa bug. Increase the reservation size in the code.");
abort();
paramList->Size * sizeof(struct gl_program_parameter));
}
- if (oldValNum + reserve_values > paramList->SizeValues) {
- paramList->SizeValues += 4 * reserve_values;
+ if (needSizeValues > paramList->SizeValues) {
+ paramList->SizeValues = needSizeValues + 16; /* alloc some extra */
paramList->ParameterValues = (gl_constant_value *)
align_realloc(paramList->ParameterValues, /* old buf */
- oldValNum * 4 * sizeof(gl_constant_value),/* old sz */
+ oldValNum * sizeof(gl_constant_value),/* old sz */
/* Overallocate the size by 12 because matrix rows can
* be allocated partially but fetch_state always writes
* 4 components (16 bytes).
*/
- paramList->SizeValues * 4 * sizeof(gl_constant_value) +
+ paramList->SizeValues * sizeof(gl_constant_value) +
12, 16);
}
}
unreachable("invalid parameter type");
}
+ assert(paramList->NumParameters <= paramList->Size);
+ assert(paramList->NumParameterValues <= paramList->SizeValues);
+
return (GLint) oldNum;
}