src/stdlib/object.c
/*=================================================
 * copy_or_addref_obj -- addref or copy object (if possible)
 * obj may be null
 * returns null if object neither refcountable nor copyable
 *===============================================*/
- addref or copy object (if possible)
obj may be null
returns null if object neither refcountable nor copyable
- addref or copy object ( if possible ) obj may be null returns null if object neither refcountable nor copyable
OBJECT
copy_or_addref_obj (OBJECT obj, int deep)
{
	VTABLE vtable;
	if (!obj) return NULL;
	vtable = (*obj);
	ASSERT(vtable->vtable_magic == VTABLE_MAGIC);
	if ((*vtable->isref_fnc)(obj)) {
		(*vtable->addref_fnc)(obj);
		return obj;
	} else if (vtable->copy_fnc) {
		return (*vtable->copy_fnc)(obj, deep);
	} else {
		return NULL;
	}
}
OBJECT copy_or_addref_obj ( OBJECT obj , int deep ) { VTABLE vtable ; if ( ! obj ) return NULL ; vtable = ( * obj ) ; ASSERT ( vtable -> vtable_magic == VTABLE_MAGIC ) ; if ( ( * vtable -> isref_fnc ) ( obj ) ) { ( * vtable -> addref_fnc ) ( obj ) ; return obj ; } else if ( vtable -> copy_fnc ) { return ( * vtable -> copy_fnc ) ( obj , deep ) ; } else { return NULL ; } }
copy_or_addref_obj -- addref or copy object (if possible)
 obj may be null
 returns null if object neither refcountable nor copyable
copy_or_addref_obj -- addref or copy object ( if possible ) obj may be null returns null if object neither refcountable nor copyable
/* refcounted */ /* not refcounted, but copyable */ /* not refcounted or copyable */