It is my understanding that, the array returned as "result" would be auto released. Therefore, you would want to retain it for your use, then release it later.

On Jan 19, 2010, at 4:14 PM, Philip Vallone wrote:

Thanks.. Good question. The method in question "PerformXMLXPathQuery" is a wrapper that was obtained:

http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html


NSArray *PerformXMLXPathQuery(NSData *document, NSString *query)
{
   xmlDocPtr doc;

   /* Load XML document */
doc = xmlReadMemory([document bytes], [document length], "", NULL, XML_PARSE_RECOVER);

   if (doc == NULL)
   {
       NSLog(@"Unable to parse.");
       return nil;
   }

   NSArray *result = PerformXPathQuery(doc, query);
   xmlFreeDoc(doc);

   return result;
}

How can I tell who has ownership of the Array?

Thanks!



On Jan 19, 2010, at 3:56 PM, Dave Carrigan wrote:


On Jan 19, 2010, at 12:52 PM, Dave DeLong wrote:

None of them.

According to the memory management rules, you're only responsible for objects you create via an "alloc", "new", or "copy" method, which none of these are. All of these objects are autoreleased.

Unless PerformXMLXPathQuery returns an object that you own. But if it does that, it should have been given a better name that has the word alloc, new or copy in it.

--
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/philip.vallone%40verizon.net

This email sent to philip.vall...@verizon.net

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/intrntmn%40aol.com

This email sent to intrn...@aol.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to