Permalink
Browse files

Added UKInvalidPointer constant that fills a pointer with 0x55... lik…

…e mallocdebug would do it. Also added DESTROY_DEALLOC() macro for use in dealloc methods that ensures we set pointers to UKInvalidPointer, not to nil, and thus crash when someone tries to use a deallocated object.
  • Loading branch information...
1 parent 3dda638 commit 4b07924eb9129ba2ab12d83066d5a0295cc17372 @uliwitness committed Sep 24, 2010
Showing with 11 additions and 11 deletions.
  1. +11 −11 UKHelperMacros.h
View
@@ -43,6 +43,13 @@
#endif
+#if __LP64__
+#define UKInvalidPointer ((id)0x5555555555555555)
+#else
+#define UKInvalidPointer ((id)0x55555555)
+#endif
+
+
// The following use the same syntax as the ones in GNUstep. Just cuz that's
// the closest we have to a standard for stuff like this.
//
@@ -64,22 +71,15 @@
(targ) = [(newval) retain];\
[__UKHELPERMACRO_OLDTARG release];\
} while(0)
-
-#define ASSIGNCOPY(targ,newval) do {\
- NSObject* __UKHELPERMACRO_OLDTARG = (NSObject*)(targ);\
- (targ) = [(newval) copy];\
- [__UKHELPERMACRO_OLDTARG release];\
- } while(0)
-#define ASSIGNMUTABLECOPY(targ,newval) do {\
+#define DESTROY(targ) do {\
NSObject* __UKHELPERMACRO_OLDTARG = (NSObject*)(targ);\
- (targ) = [(newval) mutableCopy];\
+ (targ) = nil;\
[__UKHELPERMACRO_OLDTARG release];\
} while(0)
-
-#define DESTROY(targ) do {\
+#define DESTROY_DEALLOC(targ) do {\
NSObject* __UKHELPERMACRO_OLDTARG = (NSObject*)(targ);\
- (targ) = nil;\
+ (targ) = UKInvalidPointer;\
[__UKHELPERMACRO_OLDTARG release];\
} while(0)

0 comments on commit 4b07924

Please sign in to comment.