View previous topic :: View next topic |
Author |
Message |
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Sun Aug 12, 2007 9:13 am Post subject: XML: to dup or not to dup? |
|
|
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 |
|
|
teqdruid
Joined: 11 May 2004 Posts: 390 Location: UMD
|
Posted: Sun Aug 12, 2007 11:28 am Post subject: |
|
|
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 |
|
|
Carlos
Joined: 19 Mar 2004 Posts: 396 Location: Canyon, TX
|
Posted: Sun Aug 12, 2007 12:00 pm Post subject: |
|
|
Thanks! |
|
Back to top |
|
|
|