FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

XML: to dup or not to dup?

 
Post new topic   Reply to topic     Forum Index -> Mango
View previous topic :: View next topic  
Author Message
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Sun Aug 12, 2007 9:13 am    Post subject: XML: to dup or not to dup? Reply with quote

I've extended DefaultSAXHandler for my app purposes, and in a short-lived run, I don't need to dup what I get from characterData. However, will that remain true if my program runs longer? Do I need to dup whatever I need from the XML?
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
teqdruid



Joined: 11 May 2004
Posts: 390
Location: UMD

PostPosted: Sun Aug 12, 2007 11:28 am    Post subject: Reply with quote

All of the strings passed into your handler methods by the parser are only valid during that method call. Once you return from the method, the parser is allowed to do whatever it wants with the memory pointed to by the string. So, if you want to use the contents of a string after you return from that method, you have to copy the contents- .dup is one way to do it.

~John
Back to top
View user's profile Send private message Send e-mail AIM Address
Carlos



Joined: 19 Mar 2004
Posts: 396
Location: Canyon, TX

PostPosted: Sun Aug 12, 2007 12:00 pm    Post subject: Reply with quote

Thanks!
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Mango All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group