Yes thank u,<div>I made it works by creating a char* buffer from the C world and copy scheme string to that buffer :</div><div>ie: </div><div><div>(define create-buffer</div><div>    (c-lambda (char-string) (pointer char)</div>


<div>      "</div><div>      int len = strlen(___arg1);</div><div>      char* buffer = (char*)malloc((len+1)*sizeof(char));</div><div>      strncpy(buffer, ___arg1, len);</div><div>      ___result_voidstar = buffer;</div>


<div>      "))</div></div><div><div>(define release-buffer</div><div>    (c-lambda ((pointer char)) void</div><div>      "free(___arg1);"))</div></div><div><br></div><div>The solution of making a still string object seems more tricky to me because the memory management between C and scheme is still not clear enough to me. I have to dive more into gambit internals..</div>
<div><br></div><div>cyrille</div><div><br></div>
<div>
<br><div class="gmail_quote">On Wed, Jul 18, 2012 at 4:32 AM, Frederick LeMaster <span dir="ltr"><<a href="mailto:fred.lemaster@gmail.com" target="_blank">fred.lemaster@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


I think the string you are pointing to in create_reader is allowed to<br>
be moved by the garbage collector when you return to scheme land. In<br>
first-type, there is no return to scheme so you string constant stays<br>
in the same place until after first_type_prime completes. I think if<br>
you search the list you can see an example of where Marc makes an<br>
object immovable by the garbage collector. Alternatively you can copy<br>
the string in the create_reader call.<br>
-Fred<br>
<div><div><br>
On Tue, Jul 17, 2012 at 7:37 PM, Cyrille Duret <<a href="mailto:cduret@gmail.com" target="_blank">cduret@gmail.com</a>> wrote:<br>
> I have created a module system for my needs far more simpler than blackhole<br>
> and I cannot integrate sxml in my module framework.<br>
> libxml2 is the best option for me.<br>
><br>
> On Tue, Jul 17, 2012 at 11:55 AM, Klaus Schilling <<a href="mailto:schilling.klaus@web.de" target="_blank">schilling.klaus@web.de</a>><br>
> wrote:<br>
>><br>
>> From: Cyrille Duret <<a href="mailto:cduret@gmail.com" target="_blank">cduret@gmail.com</a>><br>
>> Subject: [gambit-list] problem with ffi and libxml2<br>
>> Date: Tue, 17 Jul 2012 10:13:10 +0200<br>
>><br>
>> > hello,<br>
>> > I have problem to parse xml string with ffi and libxml2.<br>
>> ><br>
>> > My code is in the test file libxml-raw.scm :<br>
>> ><br>
>> > (c-declare #<<end<br>
>> ><br>
>> > #include <stdlib.h><br>
>> > #include <libxml/xmlreader.h><br>
>> ><br>
>> > xmlTextReaderPtr create_reader(const char* buffer, size_t len) {<br>
>> >   return xmlReaderForMemory(buffer, len, "_.xml", NULL, 0);<br>
>> > }<br>
>><br>
>> What are the major advantages of using libxml2 xmlreader with ffi over<br>
>> using sxml?<br>
>><br>
>> Klaus Schilling<br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> Gambit-list mailing list<br>
> <a href="mailto:Gambit-list@iro.umontreal.ca" target="_blank">Gambit-list@iro.umontreal.ca</a><br>
> <a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
><br>
</blockquote></div><br></div>