#ifndef GOwnPtr_h
#define GOwnPtr_h
+#if ENABLE(GLIB_SUPPORT)
+
#include <algorithm>
#include <wtf/Assertions.h>
#include <wtf/Noncopyable.h>
-// Forward delcarations at this point avoid the need to include GLib includes
-// in WTF headers.
-typedef struct _GError GError;
-typedef struct _GList GList;
-typedef struct _GCond GCond;
-typedef struct _GMutex GMutex;
-typedef struct _GPatternSpec GPatternSpec;
-typedef struct _GDir GDir;
-typedef struct _GHashTable GHashTable;
-typedef struct _GFile GFile;
extern "C" void g_free(void*);
namespace WTF {
template<> void freeOwnedGPtr<GMutex>(GMutex*);
template<> void freeOwnedGPtr<GPatternSpec>(GPatternSpec*);
template<> void freeOwnedGPtr<GDir>(GDir*);
-template<> void freeOwnedGPtr<GHashTable>(GHashTable*);
-template<> void freeOwnedGPtr<GFile>(GFile*);
-template <typename T> class GOwnPtr : public Noncopyable {
+template <typename T> class GOwnPtr {
+ WTF_MAKE_NONCOPYABLE(GOwnPtr);
public:
explicit GOwnPtr(T* ptr = 0) : m_ptr(ptr) { }
~GOwnPtr() { freeOwnedGPtr(m_ptr); }
void clear()
{
- freeOwnedGPtr(m_ptr);
+ T* ptr = m_ptr;
m_ptr = 0;
+ freeOwnedGPtr(ptr);
}
T& operator*() const
using WTF::GOwnPtr;
+#endif // ENABLE(GLIB_SUPPORT)
+
#endif // GOwnPtr_h
+