{
GL_Object *newobj = (GL_Object *)calloc(1, sizeof(GL_Object));
- AST(newobj != NULL);
+ if (newobj == NULL)
+ goto finish;
newobj->id = (int)type + newid;
newobj->real_id = real_name;
newobj->ref_count = 1;
- ret = newobj->id;
+
GL_Object_Hash *newobj_hash = (GL_Object_Hash *)calloc(1, sizeof(GL_Object_Hash));
- AST(newobj_hash != NULL);
+ if (newobj_hash == NULL)
+ {
+ free(newobj);
+ goto finish;
+ }
newobj_hash->item = newobj;
newobj_hash->hash_key = newid;
_add_hash(hash_base, newobj_hash);
GL_Object_Hash *newobj_hash_real = (GL_Object_Hash *)calloc(1, sizeof(GL_Object_Hash));
- AST(newobj_hash_real != NULL);
+ if (newobj_hash_real == NULL)
+ {
+ free(newobj);
+ free(newobj_hash);
+ goto finish;
+ }
newobj_hash_real->item = newobj;
newobj_hash_real->hash_key = real_name;
_add_hash(hash_base_real, newobj_hash_real);
+
+ ret = newobj->id;
}
_ostate_hash_check(hash_base);
return ret;
}
-
/* Check if the context's state contains object of a given type */
GLuint
fastpath_ostate_has_object_type(GL_Object_State *ostate, GL_Object_Type type)
if (real_obj != 0)
{
ret = fastpath_ostate_create_object(ostate, GL_OBJECT_TYPE_PROGRAM, real_obj);
-
Program_object_attached_tag *poat = NULL;
- poat = (Program_object_attached_tag *)calloc(1, sizeof(Program_object_attached_tag));
- AST(poat != NULL);
- poat->is_deleting = 0;
- poat->shader_count = 0;
+ if (ret != _COREGL_INT_INIT_VALUE)
+ {
+ poat = (Program_object_attached_tag *)calloc(1, sizeof(Program_object_attached_tag));
+ if (poat == NULL)
+ {
+ AST(poat != NULL);
+ fastpath_ostate_remove_object(ostate, GL_OBJECT_TYPE_PROGRAM, ret);
+ }
+ poat->is_deleting = 0;
+ poat->shader_count = 0;
- fastpath_ostate_set_object_tag(ostate, GL_OBJECT_TYPE_PROGRAM, ret, poat);
+ fastpath_ostate_set_object_tag(ostate, GL_OBJECT_TYPE_PROGRAM, ret, poat);
+ }
}
return ret;
if (poat->is_deleting == 0)
{
poat->is_deleting = 1;
+ /* Ref count increased when glCreateProgram/initial attach */
fastpath_ostate_remove_object(ostate, GL_OBJECT_TYPE_PROGRAM, object);
+ /* Ref count increased when glCreateProgram/create object */
+ /* So, we have to call the under function twice.*/
+ fastpath_ostate_remove_object(ostate, GL_OBJECT_TYPE_PROGRAM, object);
}
}
else