Re: [PATCH] Move custom icons when copying metadata
- From: dannym <danny milo gmx net>
- To: Christian Neumair <chris gnome-de org>
- Cc: nautilus-list gnome org, Alexander Larsson <alexl redhat com>
- Subject: Re: [PATCH] Move custom icons when copying metadata
- Date: Mon, 26 Sep 2005 20:29:20 +0200
Hi,
Am Montag, den 26.09.2005, 16:49 +0200 schrieb Christian Neumair:
> Am Montag, den 26.09.2005, 12:28 +0200 schrieb Alexander Larsson:
> > You're mixing g_free/xmlFree in:
> > + property = xmlGetProp (destination_file_node, NAUTILUS_METADATA_KEY_CUSTOM_ICON);
> > + if (property != NULL && g_str_has_prefix (property, source_file_uri)) {
> > + p = property;
> > +
> > + property = g_strconcat (destination_file_uri,
> > + property + strlen (source_file_uri),
> > + NULL);
> > + xmlSetProp (destination_file_node, NAUTILUS_METADATA_KEY_CUSTOM_ICON, property);
> > +
> > + xmlFree (p);
> > + }
> > +
> > + xmlFree (property);
> >
> > I recommend using p for the g_strconcat result instead and then
> > g_free(p).
>
> Maybe sb. could explain me what the influence of char signedness is in
> practice, and in what conditions I can safely "mix" xmlChar and
> (g)chars? I supposed I'm not supposed to mix them at all - hence the
> namespacing? What if the numeric value of an xmLChar is greater than the
> value a char is able to take and I pass it to g_strconcat?
xmlChar* are strings that aren't neccessarily used by only one place.
libxml2 uses some kind of aggressive memory saving strategy where it
uses the same xmlChar* address for strings that contain the same text
(one copy, as opposed to just having multiple copies of the string
around, nevertheless).
<a id="foo">
</a>
<b id="foo">
</b>
-> allocates ONE char[] "foo" and lets both point on the same.
this is also why xmlFree should be used to free it.
Then again, these might be libxml2 internal details that don't need to
be worried about from a client's perspective. Not sure.
About the signedness: I have absolutely no idea what's up with C
libraries mixing signed/unsigned char for strings (or having
null-terminated strings at all, for that matter). History, I guess.
(I certainly cannot see one single use to have char signed now - but I
guess it made sense when the charset was US ascii which was only 7 bit
safe - and you would want to know when you trashed the 8th one :))
Note that gcc 4.0.2 is very picky about mixing signed/unsignedness, so
be prepared to cast xmlChar <-> char* around like crazy (and maybe use a
gcc 4.x version for testing).
>
> > Its sort of strange that the metafile system special-cases a specific
> > key entry like this. It would make more sense to e.g. store the custom
> > icon with a relative filename. That would work for more cases than the
> > prefix of the uri being identical too. For instance when there are
> > symlinks etc involved.
>
> Yup, I've had something like that on plate already. However, it didn't
> seem trivial to make a relative out of two full URIs. Also, I wanted to
> fix this in a way that does not force users to re-pick icons for their
> existing folders.
cheers,
Danny
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]