Surendra Singhi wrote:

> Yes, this style of returning strings has been changed.
> In most of the places the new release returns a malloced C-string which is
> declared as `:malloc-free' so that c-lisp can garbage collect (or free it)
> when no-longer in use. 
> This doesn't causes any memory leaks as the reference variable is not being
> copied.

Thanks. I've downloaded the wxcl-1.2.0 and looks like the C source is no
longer included, but in the CVS the DLLs are included. In general you
should not add build results to the SVN, but provide it as released files,
only and perhaps you should release the whole source with every release,
too (write a script or Makefile to automate the build and release process).

I didn't found any documentation, but looks like eljtextctrl.cpp is used
for the C part of the library. I've found this function in it:

EWXWEXPORT(char*, wxTextCtrl_GetValue)(void* _obj)
{
        wxString result =((wxDirDialog*)_obj)->GetPath();
        char *buf = (char*)malloc((1+result.Length())*sizeof(char));
        if (buf) strcpy (buf, result.c_str());
        return buf;
}

There are 2 bugs: first you should cast it to wxTextCtrl*, not
wxDirDialog*. And I'm not sure, but if wxString is really like std::string,
then it is possible that there are binary nulls in the string data (but not
very likely in text controls), so strcpy doesn't work and handling it as a
C-string on the Lisp side doesn't work, too. This should be fixed for every
wxString parameter.

I don't know how it is defined in Common Lisp, but at least in LispWorks
and CLISP this line:

(loop for i across (concatenate 'string "x" (string (code-char 0)) "y") do
(format t "~a~%" (char-code i)))

shows this output (and the length of the string is 3 in both
implementations) :

120
0
121

so it looks like it is possible to include binary nulls within Common Lisp
strings, too, and this should be done for the wxString return type.

But perhaps this is already solved with your new CFFI port.

-- 
Frank Buß, [EMAIL PROTECTED]
http://www.frank-buss.de, http://www.it4-systems.de

_______________________________________________
Gardeners mailing list
[email protected]
http://www.lispniks.com/mailman/listinfo/gardeners

Reply via email to