A list for the developers of CellML tools

Text archives Help


[cellml-dev] CellML wchar sizes


Chronological Thread 
  • From: ak.miller at auckland.ac.nz (Andrew Miller)
  • Subject: [cellml-dev] CellML wchar sizes
  • Date: Sat, 05 Dec 2009 10:33:02 +1300

Lucian Smith wrote:
> One final question, on memory management. Before I was using XPCOM, I had
> figured out (I think) how to add and remove the references from these
> pointers. But now there seems to be a new syntax for adding refs (the
> getter_AddRefs() bit), and while you have consistently used that function
> in your examples, I have seen examples online that do not. What is the
> deal there, and when do I need to call AddRefs and when do I not, and when
> (if ever) would I need to call a ReleaseRefs() function, which I have not
> seen, but which I am postulating the existence of?

See https://developer.mozilla.org/en/Using_nsCOMPtr/Reference_Manual
about nsCOMPtr, which does memory management automatically.

If you have a raw pointer, you can explicitly use NS_ADDREF(ptr) and
NS_RELEASE(ptr), but you would very rarely want to do that.

getter_AddRefs is used by XPCOM when you have a function which takes a
pointer to a pointer to an XPCOM object, and assigns an object which
already has its reference count incremented to the value -
getter_AddRefs will ensure that the value at the pointer it supplies
ends up being put into the nsCOMPtr.

Best wishes,
Andrew

>
> -Lucian
> _______________________________________________
> cellml-tools-developers mailing list
> cellml-tools-developers at cellml.org
> http://www.cellml.org/mailman/listinfo/cellml-tools-developers





Archive powered by MHonArc 2.6.18.

Top of page