| I have trouble allocating memory, my program crashes on the second run.

| Memory, C Variables, and Pointers | Next

Q: | I have problems with allocating memory with TIGCC. When I run my program the first time, it works just as expected, but the second (or sometimes the third) time I run it, it hangs. Typical memory allocation problem. But I just can't understand what the problem is.
A: | The problem is very probably not related to the dynamic memory allocation, but to the usage of static variables. At the moment, all static vars need to be initialized, even to nothing. I.e, you need to use
    static int a = 0, b = 0;
    static char *ptr = NULL;
instead of
    static int a, b;
    static char *ptr;
I expect that this will solve your problems. I hope that Xavier will implement automatic initialization of all static data in the near future.