Hello PJ,

Saturday, May 10, 2008, 1:45:29 AM, you wrote:

> Q: Does that look ok?  Is the db <- newCString leaking ?

yes. use withCString instead

> void  GetStringValues( char* s1, char* s2);

if this functions fills s1 and s2, use alloca and peekCString

one example of (rather generic) wrapper for C functions that accepts
string (c_method) and returns string (c_out_method):

generalDoWithMethod mType c_action method = do
  withCString method $ \c_method -> do
    allocaBytes aMAX_METHOD_STRLEN $ \c_out_method -> do
      ret <- c_action c_method c_out_method
      case ret of
        0 -> peekCString c_out_method
        _ -> fail$ "Unsupported "++mType++" method or error in parameters: 
"++method


-- 
Best regards,
 Bulat                            mailto:[EMAIL PROTECTED]

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to