[xml] libxml string handling
- From: Stefan Kost <kost imn htwk-leipzig de>
- To: xml gnome org
- Subject: [xml] libxml string handling
- Date: Thu, 13 Jun 2002 09:47:33 +0200
a while ago, there ws a discussion about string handling in libxml (too many strdups).
what about this approach :
>>>>
from : http://www.redland.opensource.ac.uk/docs/api/objects.html
It is often convienent to get a string representation of an object for
further processing, debugging or serialisation. There are two
conventions for methods that provide this functionality - the first is
when a pointer is returned to a shared copy of the string and in that
case the method ends _as_string. The second is when a pointer is
returned to a newly allocated string in which case the method ends
_to_string.
<<<<
so we basically rename all the currently affected methods to end with _as_string
and just return the pointer plu we provided functions _ending in _to_string
which call the _to_string and strdup it. We further provided #defines to redirect
calls of the original name to the _to_sting function plus issuing
a compiler warning about deprecation via #warning.
I am not totally sure which way to go for functions which generate the
resulting string. One can aleways use a static buffer therefore,
but that can easilly lead to stange effect (one can only use it as long
as it not calls the function again).
Stefan
--
\|/
<@ @> Stefan Kost private business
+-oOO-(_)-OOo------------------------------------------------------------- - - - - -
| __ Address Zwenkauer Str. 24 HTWK Leipzig, Fb IMN, Postfach 300066
| /// 04277 Leipzig 04277 Leipzig
| __ /// Germany Germany
| \\\/// Phone +49341 3910483 +49341 30766101
| \__/ EMail st_kost gmx net kost imn htwk-leipzig de
| WWW http://www.sonicpulse.de http://www.imn.htwk-leipzig.de/~kost/about.html
===-=-=--=---=---------------------------------- - - - - -
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]