A89: Re: memory problems in ti-gcc.


[Prev][Next][Index][Thread]

A89: Re: memory problems in ti-gcc.




Hi!

> Hi, now it is my turn too ask a question.
> I have problems with allocating memory with ti-gcc.
> When I run this 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.
> I have tried to not use malloc and free and used 
> HeapAlloc, and HeapFree (and HeapDeref ofcourse) too, but
> it makes no difference. I have even tried to remove the 
> grayscale part, since I thought it could interfere, but no
> difference. The first version I did, read the playfield 
> from a static var, and that worked perfectly, so It is 
> unlikely it is anything else then memory handling..
> So... please tell... what part of my brain is it that 
> doesn't work? :)

The problem is probably with static variables. Due to TIOS
limitations, all static vars need to be initialized, even
to nothing. I.e, you need to use

static char* playfield = NULL;
static void* light_gray = NULL;
static void* dark_gray = NULL; 

instead of

static char* playfield;
static void* light_gray;
static void* dark_gray; 

I expect that this will solve your problems. I really need to
contact to Xavier to tell him that he need to implement automatic
initializing of all static data...

Cheers,

Zeljko Juric




Follow-Ups: