Hey Dodji, Yes, this looks good to me. On Mon, Jul 07, 2014 at 09:54:31PM +0200, Dodji Seketeli wrote:
diff --git a/src/common/nmv-safe-ptr-utils.h b/src/common/nmv-safe-ptr-utils.h index fdeb350..72211e8 100644 --- a/src/common/nmv-safe-ptr-utils.h +++ b/src/common/nmv-safe-ptr-utils.h @@ -30,7 +30,7 @@ #ifndef __NMV_SAFE_PTR_UTILS_H__ #define __NMV_SAFE_PTR_UTILS_H__ -#include <glib.h> +#include <glib-object.h> #include "nmv-object.h" #include "nmv-safe-ptr.h" #include "nmv-namespace.h" @@ -115,11 +115,32 @@ struct GErrorUnref { } }; +struct RefGObjectNative { + void operator () (void *a_object) + { + if (a_object && G_IS_OBJECT (a_object)) { + g_object_ref (G_OBJECT (a_object)); + } + } +}; + +struct UnrefGObjectNative { + void operator () (void *a_object) + { + if (a_object && G_IS_OBJECT (a_object)) { + g_object_unref (G_OBJECT (a_object)); + } + } +}; + typedef SafePtr <gchar, CharsRef, GCharUnref> GCharSafePtr; typedef SafePtr <Object, ObjectRef, ObjectUnref> ObjectSafePtr; typedef SafePtr <gchar, CharsRef, DelCharsUnref> CharSafePtr; typedef SafePtr <gunichar, UnicharsRef, DelUnicharsUnref> UnicharSafePtr; typedef SafePtr<GError, GErrorRef, GErrorUnref> GErrorSafePtr; +typedef SafePtr<void*, + RefGObjectNative, + UnrefGObjectNative> NativeGObjectSafePtr;
Should there be a space between SafePtr and < ? Happy hacking, Debarshi -- It has its possibilities but I am bound by my limitations. -- Vivek Shah
Attachment:
pgpw70wdKGYfx.pgp
Description: PGP signature