A list for the developers of CellML tools

Text archives Help


[cellml-dev] ACStrings and wrapped MathMLElements


Chronological Thread 
  • From: lpsmith at spod-central.org (Lucian Smith)
  • Subject: [cellml-dev] ACStrings and wrapped MathMLElements
  • Date: Sat, 5 Dec 2009 00:00:00 +0000

* Andrew Miller <ak.miller at auckland.ac.nz> [2009-12-04 21:36] writes:
> 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.

Right! I remember this. This is why I was surprised to see
'getter_AddRefs()'.

> 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.

I'm afraid I don't understand this sentence. A pointer to a pointer? I
thought the CellML functions just returned pointers, not pointers to
pointers.
http://cellml-api.sourceforge.net/interfacecellml__api_1_1_cell_m_l_bootstrap.html

just says that 'createModel' returns a 'Model'. As I use other functions
from the CellML API, how will I know when I need to use 'getter_AddRefs()'
and when I don't?


In other news, https://developer.mozilla.org/en/nsString#GetData seems to
indicate that nsString objects have a 'GetData' function. However, the
code:

nsString foo;
wchar_t* foo_wchar;
foo.GetData(foo_wchar);

will not compile, complaining "'class nsString_external' has no member
named 'GetData'" What? Is the mozilla.org site lying, or is something
else going on?

-Lucian




Archive powered by MHonArc 2.6.18.

Top of page