SkRef for expressions.

https://codereview.appspot.com/6475045/


git-svn-id: http://skia.googlecode.com/svn/trunk@5238 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bungeman@google.com 2012-08-22 18:56:56 +00:00
parent 35c5ff0be8
commit 1fd201b9df

View File

@ -117,12 +117,21 @@ private:
} while (0)
/** Check if the argument is non-null, and if so, call obj->ref()
/** Call obj->ref() and return obj. The obj must not be NULL.
*/
template <typename T> static inline void SkSafeRef(T* obj) {
template <typename T> static inline T* SkRef(T* obj) {
SkASSERT(obj);
obj->ref();
return obj;
}
/** Check if the argument is non-null, and if so, call obj->ref() and return obj.
*/
template <typename T> static inline T* SkSafeRef(T* obj) {
if (obj) {
obj->ref();
}
return obj;
}
/** Check if the argument is non-null, and if so, call obj->unref()