+ return false;
+ }
+ return true;
+}
+
+
+/**
+ * Helper function for_mesa_PushAttrib for simple attributes.
+ * Allocates memory for attribute data and copies the given attribute data.
+ * \param head head of linked list to insert attribute data into
+ * \param attr_bit one of the GL_<attrib>_BIT flags
+ * \param attr_size number of bytes to allocate for attribute data
+ * \param attr_data the attribute data to copy
+ * \return true for success, false for out of memory
+ */
+static bool
+push_attrib(struct gl_context *ctx, struct gl_attrib_node **head,
+ GLbitfield attr_bit, GLuint attr_size, const void *attr_data)
+{
+ void *attribute;
+
+ attribute = malloc(attr_size);
+ if (attribute == NULL) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib");
+ return false;
+ }
+
+ if (save_attrib_data(head, attr_bit, attribute)) {
+ memcpy(attribute, attr_data, attr_size);
+ }
+ else {
+ free(attribute);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib");
+ return false;