Allow NULL for all parameters in object.c.
This commit is contained in:
parent
38f3cbd511
commit
72046b604b
1 changed files with 27 additions and 0 deletions
27
src/object.c
27
src/object.c
|
@ -94,6 +94,9 @@ cfw_ref(void *ptr)
|
|||
{
|
||||
CFWObject *obj = ptr;
|
||||
|
||||
if (obj == NULL)
|
||||
return NULL;
|
||||
|
||||
obj->ref_cnt++;
|
||||
|
||||
return obj;
|
||||
|
@ -104,6 +107,9 @@ cfw_unref(void *ptr)
|
|||
{
|
||||
CFWObject *obj = ptr;
|
||||
|
||||
if (obj == NULL)
|
||||
return NULL;
|
||||
|
||||
if (--obj->ref_cnt == 0)
|
||||
cfw_free(obj);
|
||||
}
|
||||
|
@ -113,6 +119,9 @@ cfw_free(void *ptr)
|
|||
{
|
||||
CFWObject *obj = ptr;
|
||||
|
||||
if (obj == NULL)
|
||||
return NULL;
|
||||
|
||||
if (obj->cls->dtor != NULL)
|
||||
obj->cls->dtor(obj);
|
||||
|
||||
|
@ -124,6 +133,9 @@ cfw_class(void *ptr)
|
|||
{
|
||||
CFWObject *obj = ptr;
|
||||
|
||||
if (obj == NULL)
|
||||
return NULL;
|
||||
|
||||
return obj->cls;
|
||||
}
|
||||
|
||||
|
@ -132,6 +144,9 @@ cfw_is(void *ptr, CFWClass *cls)
|
|||
{
|
||||
CFWObject *obj = ptr;
|
||||
|
||||
if (obj == NULL || cls == NULL)
|
||||
return false;
|
||||
|
||||
return (obj->cls == cls);
|
||||
}
|
||||
|
||||
|
@ -140,6 +155,12 @@ cfw_equal(void *ptr1, void *ptr2)
|
|||
{
|
||||
CFWObject *obj1 = ptr1, *obj2 = ptr2;
|
||||
|
||||
if (obj1 == obj2)
|
||||
return true;
|
||||
|
||||
if (obj1 == NULL || obj2 == NULL)
|
||||
return false;
|
||||
|
||||
if (obj1->cls->equal != NULL) {
|
||||
return obj1->cls->equal(obj1, obj2);
|
||||
} else
|
||||
|
@ -151,6 +172,9 @@ cfw_hash(void *ptr)
|
|||
{
|
||||
CFWObject *obj = ptr;
|
||||
|
||||
if (obj == NULL)
|
||||
return 0;
|
||||
|
||||
if (obj->cls->hash != NULL)
|
||||
return obj->cls->hash(obj);
|
||||
|
||||
|
@ -162,6 +186,9 @@ cfw_copy(void *ptr)
|
|||
{
|
||||
CFWObject *obj = ptr;
|
||||
|
||||
if (obj == NULL)
|
||||
return NULL;
|
||||
|
||||
if (obj->cls->copy != NULL)
|
||||
return obj->cls->copy(obj);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue