1 // Test04.cpp 2 3 #include "nsINode.h" 4 #include "nsCOMPtr.h" 5 6 NS_DEF_PTR(nsINode); 7 8 /* 9 Windows: 10 nsCOMPtr 13 raw 11 36 12 13 Macintosh: 14 nsCOMPtr 15 36 bytes (1.0000) raw 16 120 (3.3333) i.e., 333.33% bigger 17 than nsCOMPtr 18 */ 19 20 class Test04_Raw { 21 public: 22 Test04_Raw(); 23 ~Test04_Raw(); 24 25 void /*nsresult*/ SetNode(nsINode* newNode); 26 27 private: 28 nsINode* mNode; 29 }; 30 Test04_Raw()31Test04_Raw::Test04_Raw() : mNode(0) { 32 // nothing else to do here 33 } 34 ~Test04_Raw()35Test04_Raw::~Test04_Raw() { NS_IF_RELEASE(mNode); } 36 37 void // nsresult SetNode(nsINode * newNode)38Test04_Raw::SetNode(nsINode* newNode) 39 // m120, w36 40 { 41 NS_IF_ADDREF(newNode); 42 NS_IF_RELEASE(mNode); 43 mNode = newNode; 44 45 // return NS_OK; 46 } 47 48 class Test04_nsCOMPtr { 49 public: 50 void /*nsresult*/ SetNode(nsINode* newNode); 51 52 private: 53 nsCOMPtr<nsINode> mNode; 54 }; 55 56 void // nsresult SetNode(nsINode * newNode)57Test04_nsCOMPtr::SetNode(nsINode* newNode) 58 // m36, w13/13 59 { 60 mNode = newNode; 61 } 62