From: mental Date: Fri, 9 Mar 2007 00:32:53 +0000 (+0000) Subject: address type-punned pointer warning X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0a0cebf42aadd0a682e4961b1e23c13f2df7555a;p=inkscape.git address type-punned pointer warning --- diff --git a/src/gc-soft-ptr.h b/src/gc-soft-ptr.h index a055ba38c..539eac678 100644 --- a/src/gc-soft-ptr.h +++ b/src/gc-soft-ptr.h @@ -27,19 +27,16 @@ namespace GC { template class soft_ptr { public: - soft_ptr(T * const &pointer=NULL) : _pointer(pointer) { - _register(); - } - soft_ptr(soft_ptr const &other) : _pointer(other._pointer) { + soft_ptr(T *pointer=NULL) : _pointer(pointer) { _register(); } - operator T *() const { return _pointer; } - T &operator*() const { return *_pointer; } - T *operator->() const { return _pointer; } - T &operator[](int i) const { return _pointer[i]; } + operator T *() const { return static_cast(_pointer); } + T &operator*() const { return *static_cast(_pointer); } + T *operator->() const { return static_cast(_pointer); } + T &operator[](int i) const { return static_cast(_pointer)[i]; } - soft_ptr &operator=(T * const &pointer) { + soft_ptr &operator=(T *pointer) { _pointer = pointer; return *this; } @@ -50,11 +47,11 @@ private: void _register() { void *base=Core::base(this); if (base) { - Core::general_register_disappearing_link((void **)&_pointer, base); + Core::general_register_disappearing_link(&_pointer, base); } } - T *_pointer; + void *_pointer; }; }