I have a c method that returns a const char *
and I imported this function into my specman code. After executing few more statements in "e" the value in the string is getting corrupted. I guess may be because it is referring to a pointer in C space.
C signature:
const char* myFun(const char* key)
{
static string myVal;
myVal = myDictionary[key];
return myVal.c_str();
}
in e:
myFun(key : string) : string is foreign dynamic C routine
in e usage:
var str : string;
var str2 : string;
str = myFun("my_test");
outf("%s",str) ---> here it gives the correct value
str2 = myFun("my_test2");
----------
----------
outf("%s",str) ---> here it gives some garbage value, statements in the middle doesn't edit this string in anyway.
thoughts on what is wrong with this code?