Privacy and Security Notice

Archived Messages for CDEV_1997@cebaf.gov: get problem

get problem

Johannes van Zeijts (johannes@CEBAF.GOV)
Tue, 25 Mar 1997 11:49:48 -0500

I have found a serious problem with get, when I pass it a char*

Consider the code below, I am asking for 255 chars of data (I allocated
256). SYMPTOM: In the first iteration through the loop, the value of i
is overwritten and ends up being some large integer.

Changing the order of declaration to:
int i;
char res[256];

fixes the problem. Looks like cdev is putting more in than I want.

-Johannes

void TclCdevCollection::getResult(Tcl_Interp *interp) {
char res[256];
int i;
for (i = 0; i < ndevices; i++) {
results[i].get(VALUE_TAG, res, 255);
cout << i << endl;
// Tcl_AppendElement(interp, res);
}
}