Mail Archives: djgpp/1998/01/09/03:31:41
>
>At 05:59 12/31/1997 +1030, Richard Sim wrote:
>>Hi, I just spent several days trying to get a routine working because I
>>forgot to allocate 5 bytes of memory, and I was wondering if there are any
>>programs/documents that tell you what needs to have memory allocated to it.
>>i.e. Goes through your code and finds things that need memory allocated to
>>them, or a text that explains things like this...
>>Just if you didn't have to allocate memory all of the time...or if there was
>>something that would tell you what you have to allocate memory for and what
>>you don't :-).
>>Oh well, if anyone knows of anything like this could they please tell me
>>since I really need it. :-)
>Try compiling with `-Wall'. This may find problems with accessing
>unallocated memory.
>Basically, almost every time you pass a pointer to a function, the pointer
>should point at something accessible. If the data is going to be changed, it
>needs to not be a constant.
>>
>>Also, if say you allocate a structure, do you have to do a free at the end
>>of your program, or will it be totally free'd anyway? I know that you
>>should, but must you?
>No. All memory is automatically freed when your program exits. This should
>be the case on every system.
>
>Nate Eldredge
>eldredge AT ap DOT net
>
>
It's good practice to explicitly allocate and free memory....
int x; <= NO - you don't have to do a malloc... ; )
(this part is allegro stuff)
BITMAP *boogy;
boogy = create_bitmap(320x200);
destroy_bitmap(boogy);
Note: load_bitmap will allocate the memory for you... so you don't have to call
create_bitmap first...
I go with Nate - that it's not an absolute
- but it sucks when things crash - allocate your memory (it might help you keep
track of it better too!)
Jim the loiterer (wannabe PC game/graphics developer)
http://members.aol.com/qball1723/index.htm
[please don't hate me because I pay too much for poor internet service!!]
- Raw text -