At 11:15 AM +0100 11/11/04, Bernhard Schmalhofer wrote:
Leopold Toetsch wrote:

>>This means that the string buffer has to stay around, until the parsing is
done.


 This is what the "t" signature char is doing anyway - Oops or better,
 what it should to. While it's using string_to_cstring the created string
 isn't freed (unless the library would free it, which is unlikely).

Actually it is freed right after the external function call. Which is bad when the freed memory is accessed later.

No, that's not bad.

The problem is that you're using the wrong signature type here. 't' is for plain c strings passed into functions for temporary usage. It is *not* for passing in of long-lived buffers. You really want the 'b' type if it's a long-lived thing. That pulls the buffer pointer out of the string structure and passes it in, so it's suitable for mutable stuff. (That's what it's there for, actually)

I think maybe the docs for this need some updating. I'll go do that while I'm waiting for tests to churn.
--
Dan


--------------------------------------it's like this-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to