[m-rev.] Fwd: for review: fix obsolete tcl-tk code in extras/graphics/mercury_tcltk
Julien Fischer
jfischer at opturion.com
Fri Jan 7 23:08:51 AEDT 2022
Hi Fabrice,
On Thu, 6 Jan 2022, Fabrice Nicol wrote:
> Hi Julien,
>> According the Tcl/Tk documentation TCL_DYANMIC is for when the memory
>> referenced by the result field is allocated using the Tcl_Alloc()
>> function. (Memory allocated by Mercury's GC is definitely *not*
>> allocated using this function.)
>>
>> I think the safest approach here is to get the result string from
>> Mercury, copy it into memory allocated using Tcl_Alloc() and then
>> pass that to Tcl_SetResult().
>>
> Ok, I hope the attached patch sets things straight if TCL_DYNAMIC is to be
> preferred.
Just one question: why are you only copying the first 2047 bytes of
the string instead of copying the entire string?
> In the process, I added a missing foreign_enum pragma for Mercury type
> 'tcl_status' (see commit message).
Thanks for that. The Tcl/Tk binding predates the addition of
foreign_enum pragmas to the language. The existing code just happened
to (nearly always) work because the values of the C constants matched
the representation Mercury uses for values of that type.
Julien.
More information about the reviews
mailing list