xpcom/tests/SizeTest04.cpp
author divyansh <sharma.divyansh.501@iitg.ernet.in>
Tue, 09 Oct 2018 18:23:15 +0000
changeset 496051 dd0480856174ebb56abe03c063f4833f8c4f5d43
parent 474612 220898648f5f735a4372d824f74e45acb66907ae
child 507657 09c71a7cf75aeaf2963050e315276fb9a866fd62
permissions -rw-r--r--
Bug 1423843 - Enabled ESLint for dom/notification/test/unit r=Standard8,mccr8 Differential Revision: https://phabricator.services.mozilla.com/D8026

// Test04.cpp

#include "nsINode.h"
#include "nsCOMPtr.h"

NS_DEF_PTR(nsINode);

	/*
		Windows:
			nsCOMPtr							 13
			raw										 36

		Macintosh:
			nsCOMPtr							 36 bytes		(1.0000)
			raw										120					(3.3333)	i.e., 333.33% bigger than nsCOMPtr
	*/

class Test04_Raw
	{
		public:
			Test04_Raw();
		 ~Test04_Raw();

			void /*nsresult*/ SetNode( nsINode* newNode );

		private:
			nsINode* mNode;
	};

Test04_Raw::Test04_Raw()
		: mNode(0)
	{
		// nothing else to do here
	}

Test04_Raw::~Test04_Raw()
	{
		NS_IF_RELEASE(mNode);
	}

void // nsresult
Test04_Raw::SetNode( nsINode* newNode )
		// m120, w36
	{
		NS_IF_ADDREF(newNode);
		NS_IF_RELEASE(mNode);
		mNode = newNode;

//		return NS_OK;
	}



class Test04_nsCOMPtr
	{
		public:
			void /*nsresult*/ SetNode( nsINode* newNode );

		private:
			nsCOMPtr<nsINode> mNode;
	};

void // nsresult
Test04_nsCOMPtr::SetNode( nsINode* newNode )
		// m36, w13/13
	{
		mNode = newNode;
	}