Closed the4thamigo-uk closed 6 years ago
I have a feeling you need to release the *xmlError
struct somewhere?
Ah ok, but do you also have this problem then in XMLC14NDocDumpMemory()
Also, I agree that having this is better than not, but can you please note in the comment somewhere that in the future, we should probably be formatting the error message in C land, and not in Go (and therefore use xmlParserError
or some other function that I may have overlooked).
If we can just fetch the error message from C, and worry about that alone, I think it's much better than mucking with C structs (i.e. xmlError
) in Go land
Ah ok, but do you also have this problem then in XMLC14NDocDumpMemory
Well, then you might have found another memory bug :)
Not sure though, because no copy is made when returning, so I think it is correct not to free it :
https://github.com/GNOME/libxml2/blob/35e83488505d501864826125cfe6a7950d6cba78/error.c#L924
Oh interesting. Thanks for the pointer! Yeah, that looks like it belongs in the context. Can you keep a note of this in the comment too? I'm sure I'm going to scratch my head in the future on the same line :D
The remaining concern I have is whether we should reconstruct the error message formatted with the line number etc as you would see it in std out... or whether we should wrap the error structure so that the library user can format the error how they want (the more complete fix) .
Updated the commit comment as requested.
Well, I think for the time being this should suffice:
ParseXXX
function just like what you would see in stdout.If I were the end user, I think I'd expect the GetLastError
function to return a wrapper (or some copy) of the underlying *xmlError
structure. So I think that function should return a struct. But the parser function can return whatever, really.
Yup ok, will do
Have updated the commit.
P.S. the error message 'failed to document' in the existing code doesnt mean a lot to me. How are you meant to interpret that as a user of the library?
That's probably one of those cut n paste (then a mass replace) things that got left over. Feel free to fix that in this PR or send me an issue so I don't forget :)
Oh shall I move the xmlCtxtLastError function to be near to ReportErrors
?
You mean physical placement? I really have no preference there. Your call.
Well, I have to go take care of the kids now. Let me know when you finish the PR, and I will merge later. Thanks for your contribution!
Ok I moved it. Think its done, so long as it passes checks.
fixes #52