[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 01/29] Introduce QObject

From: Paolo Bonzini
Subject: [Qemu-devel] Re: [PATCH 01/29] Introduce QObject
Date: Thu, 20 Aug 2009 10:51:58 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3

+ *  - New reference: means that the caller is now the owner of a reference,
+ *    for example, if you call a function that returns a 'new reference' you
+ *    must call QDECREF() when you are done
+ *
+ *  - Borrowing a reference: nothing needs to be done, you are not the
+ *    owner of the reference
+ *
+ *  - Stealing a reference: when you pass a reference to a function that
+ *    'steals a reference' this function assumes that it now owns that
+ *    reference

I think the usual terms used here would be like

   - Returning references: A function that returns an object may
   return it as either a weak or a strong reference.  If the reference
   is strong, you are responsible for calling QDECREF() on the reference
   when you are done.

   If the reference is weak, the owner of the reference may free it at
   any time in the future.  Before storing the reference anywhere, you
   should call QINCREF() to make the reference strong.

   - Transferring ownership: when you transfer ownership of a reference
   by calling a function, you are no longer responsible for calling
   QDECREF() when the reference is no longer needed.  In other words,
   when the function returns you must behave as if the reference to the
   passed object
   was weak.

I'll post examples of using this terminology in the review of QDict.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]