From: Sharma Anshoo-A. <an...@mo...> - 2003-07-01 11:39:34
|
Hi, We are facing a few some issues after integrating our application with TCL. We are running TCL on Win2k Platform. The problem is with the string variables that we have shared across TCL and C code. During the Initialization we request TCL to allocate a pointer "p_tcl_c_str" (say 1024 bytes) using the Tcl_Alloc call. When we later write to this variable from a TCL Script, TCL reallocates this variable memory which is equal to length of the string that is being written. For Example if we do a "set p_tcl_c_str Hello_World", It will reallocate this variable only 12 bytes and release the previous chunk. As, in the C code we are not aware of this change we write to the C variable expecting that it would be able to support the write upto 1024 bytes and hence the process crashes. Can someone please suggest the recommended mechanism for reading / writing string variables across TCL and C. We do not want to allocate memory in C for the string variable everytime we change the contents of the string. All help is appreciated. Thanks and Regards Anshoo. |