+ if (stack->Depth + 1 >= stack->StackSize) {
+ unsigned new_stack_size = stack->StackSize * 2;
+ unsigned i;
+ GLmatrix *new_stack = realloc(stack->Stack,
+ sizeof(*new_stack) * new_stack_size);
+
+ if (!new_stack) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushMatrix()");
+ return;
+ }
+
+ for (i = stack->StackSize; i < new_stack_size; i++)
+ _math_matrix_ctr(&new_stack[i]);
+
+ stack->Stack = new_stack;
+ stack->StackSize = new_stack_size;
+ }
+