I have a c method that returns a
const char *
const char* myFun(const char* key)
static string myVal;
myVal = myDictionary[key];
myFun(key : string) : string is foreign dynamic C routine
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.
In e strings are immutable, there is no legal way to change its contents. I think you need to look into your C code - it probably does some reuse to the memory of the string it sent to e in the previous call. If pointer to C string is passed to e and not immediately disposed in e code, it can be copied, as a precaution, with .copy(), for example.