Re: about xmlReadMemory()
nicolas bats via xml <[email protected]> Wed, 3 Mar 2021 09:30:44 +0100
| Newsgroups | gmane.comp.gnome.lib.xml.general |
|---|---|
| Message-ID | <CAPb79oXPvaARLn236tzC+G_LsQc+Z2EgJJcL2N-DbXm50cOqBw@mail.gmail.com> |
--===============4167252617130210599== Content-Type: multipart/alternative; boundary="0000000000007c8d7905bc9dab65" --0000000000007c8d7905bc9dab65 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Nick, I've experimented with xmlReadIO and it's cool. this message just to check I'm doing right: -I register an xmlInputReadCallback of type: size_t myCallback(void* context, char* buffer, int length) -I do my stuff in the callback and if data I use exceed the length of the buffer, I realloc it. Is this schema good? Do I need to set size_t as the return type of myCallback? thank you for your enlightenment . best regards, nicolas Le mar. 2 mars 2021 =C3=A0 19:32, nicolas bats <[email protected]> a =C3= =A9crit : > Thank you Nick for your answer, I'll give a try to xmlReadIO. > thanks again. > ++ > > Le mar. 2 mars 2021 =C3=A0 18:02, Nick Wellnhofer <[email protected]> a > =C3=A9crit : > >> On 02/03/2021 16:28, nicolas bats via xml wrote: >> > Hi, >> > is there's a reason why xmlReadMemory >> > <http://xmlsoft.org/html/libxml-parser.html#xmlReadMemory>() accepts >> int as >> > the size of the array to transform to xmlDocPtr. >> > no doubt there's one... >> >> That's simply a design mistake. The API was created 20 years ago when >> 64-bit >> systems were rare. >> >> > and in that case how could I retrieve a xmlDocPtr from >> > memory where size is type of size_t? >> >> If you want to process memory buffers larger than INT_MAX, you can use >> xmlReadIO with a custom read callback that uses a size_t to store the >> offset. >> >> Nick >> > --0000000000007c8d7905bc9dab65 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Hi Nick,<div>I've experimented with=C2=A0<span style= =3D"color:rgb(0,0,0)">xmlReadIO and it's cool.</span></div><div><font c= olor=3D"#000000">this message just to check I'm doing right:</font></di= v><div><font color=3D"#000000">-I register an xmlInputReadCallback of type:= size_t myCallback(void* context, char* buffer, int length)</font></div><di= v><font color=3D"#000000">-I do my stuff in the callback and if data I use = exceed the length of the buffer, I realloc it.</font></div><div><font color= =3D"#000000">Is this schema good?</font></div><div><font color=3D"#000000">= Do I need to set size_t as the return type of myCallback?</font></div><div>= <font color=3D"#000000"><br></font></div><div><font color=3D"#000000">thank= you for your enlightenment=C2=A0.</font></div><div><font color=3D"#000000"= >best regards,</font></div><div><font color=3D"#000000">nicolas</font></div= ><div><font color=3D"#000000"><br></font></div></div><br><div class=3D"gmai= l_quote"><div dir=3D"ltr" class=3D"gmail_attr">Le=C2=A0mar. 2 mars 2021 =C3= =A0=C2=A019:32, nicolas bats <<a href=3D"mailto:[email protected]" tar= get=3D"_blank">[email protected]</a>> a =C3=A9crit=C2=A0:<br></div><bl= ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef= t:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">Thank=C2=A0= you Nick for your answer, I'll give a try to=C2=A0<span style=3D"color:= rgb(0,0,0)">xmlReadIO.</span><div><span style=3D"color:rgb(0,0,0)">thanks a= gain.</span></div><div><span style=3D"color:rgb(0,0,0)"><a class=3D"gmail_p= lusreply" id=3D"gmail-m_-8406994502122364322gmail-m_2581323396883386094plus= ReplyChip-1">++</a><br></span></div></div><br><div class=3D"gmail_quote"><d= iv dir=3D"ltr" class=3D"gmail_attr">Le=C2=A0mar. 2 mars 2021 =C3=A0=C2=A018= :02, Nick Wellnhofer <<a href=3D"mailto:[email protected]" target=3D"_= blank">[email protected]</a>> a =C3=A9crit=C2=A0:<br></div><blockquote= class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px so= lid rgb(204,204,204);padding-left:1ex">On 02/03/2021 16:28, nicolas bats vi= a xml wrote:<br> > Hi,<br> > is there's a reason why xmlReadMemory <br> > <<a href=3D"http://xmlsoft.org/html/libxml-parser.html#xmlReadMemor= y" rel=3D"noreferrer" target=3D"_blank">http://xmlsoft.org/html/libxml-pars= er.html#xmlReadMemory</a>>() accepts int as <br> > the size of the array to transform to xmlDocPtr.<br> > no doubt there's one...<br> <br> That's simply a design mistake. The API was created 20 years ago when 6= 4-bit <br> systems were rare.<br> <br> > and in that case how could I retrieve a xmlDocPtr from <br> > memory where size is type of size_t?<br> <br> If you want to process memory buffers larger than INT_MAX, you can use <br> xmlReadIO with a custom read callback that uses a size_t to store the offse= t.<br> <br> Nick<br> </blockquote></div> </blockquote></div> --0000000000007c8d7905bc9dab65-- --===============4167252617130210599== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] https://mail.gnome.org/mailman/listinfo/xml --===============4167252617130210599==--