Re: [xml] xmlSplitQName2 problem and patch



On Thu, 2004-02-19 at 03:35, Daniel Veillard wrote:
On Wed, Feb 18, 2004 at 08:27:35AM -0800, Aleksey Sanin wrote:
But why does this function return NULL in this case?
Shouldn't it return the passed in string (in the same
way as xmlBuildQName() function does)?

  Well, that's a serious API change. I would have to modify
all the places where I use xmlSplitQName2(). This means an
API breakage. Just change it the function, and try to run libxml2
and libxslt regression tests. I bet this will lead to various
crashes. Since the implementation of the function matches its
description, I find hard to change this. You can use another function
though, like for example xmlSplitQName3() .

Isn't there also going to be a problem with who owns the returned string
with the behavious Aleksey wants? At the moment, xmlSplitQName2 returns
either a new string (that the caller frees) or NULL. If xmlSplitQName3()
was to return a pointer to the original string instead of NULL, the
caller still has to do a test to see if the returned string is the
original string in order to avoid freeing this string twice. So no code
is really saved and the API of xmlSplitQName3() is more error-prone.

Malcolm





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]