Mail Archives: djgpp/2000/12/01/14:51:50
Tom Hunt <thunt1 AT falcon DOT lhup DOT edu> wrote:
> I'm getting erratic behavior with this block of code. Sometimes the program
> crashes in load_pcx. Sometimes it doesn't.
>
> #define NUM_IMAGES 3
>
> char *names[NUM_IMAGES] = {
> "GRASS.PCX",
> "WATER.PCX",
> "FOREST.PCX"
> };
> ...
> RGB *pal;
> BITMAP *images[NUM_IMAGES];
> ...
> for(int i=0; i<NUM_IMAGES; i++)
> {
> images[i] = load_bitmap(names[i], pal);
> }
>
> When it does crash, I get a page fault from within load_pcx. Would anyone
> have an idea as to why this is happening?
An error in memory allocation elsewhere could cause problems. What's
the smallest *compilable* code segment you can post which exhibits this
behavior? Nothing jumps out at me as wrong, here.
To be pedantic, I'd suggest you declare names as const char *, but that
is almost certainly not relevant to your problem.
--
naisbodo AT enteract DOT com
http://www.naisbodo.com/
- Raw text -