Re: [racket] FFI question again - how to get a string back from C

2011-06-12 Thread keyd...@gmx.de
Hi Thomas, thanks a lot for your char * vs char** explanation! > > But if there is no sure way to guess the correct buffer size before > the function call, your only failsafe option is to invoke the function > repeatedly with increasing buffer sizes as long as it reports > failure. I see... but

Re: [racket] FFI question again - how to get a string back from C

2011-06-12 Thread Thomas Chust
2011/6/12 keyd...@gmx.de : > [...] > In fact to be honest, I do not really understand the reason why I > have to allocate a byte buffer here - what difference does it make > to a char **, shouldn't both just be consecutive places in memory > filled with ascii characters > [...] Hello Sigrid, a by

Re: [racket] FFI question again - how to get a string back from C

2011-06-11 Thread keyd...@gmx.de
Hi Thomas, thank you, too, very much for your solution! I had already successfully tried Ryan's way, but it's always good and instructive to learn several ways - now I know 2 ways to allocate a byte buffer and to cast it to a string afterwards :-) I've tried your solution, and it worked perfect

Re: [racket] FFI question again - how to get a string back from C

2011-06-11 Thread Thomas Chust
2011/6/11 keyd...@gmx.de : > [...] > I have a problem getting an output string from the C side... Hello Sigrid, it would be helpful if you mentioned the signature of the original C function, otherwise it is hard to decide whether your binding's signature is correct. I will assume that the functi

Re: [racket] FFI question again - how to get a string back from C

2011-06-11 Thread keyd...@gmx.de
Hi Ryan, thank you very much, this works very well! I am not sure yet whether it'd be desirable to pass in the buffer to the function,- it's more work for the client, but in any case, the client will have to specify the buffer length. Regarding garbage collection, it should not really make a dif

Re: [racket] FFI question again - how to get a string back from C

2011-06-11 Thread Ryan Culpepper
On 06/11/2011 12:54 AM, keyd...@gmx.de wrote: Hi again, sorry for again asking such a basic FFI question, but I have a problem getting an output string from the C side... E.g. in one case, in my first attempt (def-ocilib datetotext OCI_DateToText : (date_ptr : _pointer) (fmt : _string) (size

[racket] FFI question again - how to get a string back from C

2011-06-10 Thread keyd...@gmx.de
Hi again, sorry for again asking such a basic FFI question, but I have a problem getting an output string from the C side... E.g. in one case, in my first attempt (def-ocilib datetotext OCI_DateToText : (date_ptr : _pointer) (fmt : _string) (size : _int) (strval : (_ptr o _string)) -> (result