From: mlcrowd AT mail DOT enol DOT com Message-Id: <199801170348.UAA25385@mail.enol.com> Comments: Authenticated sender is To: djgpp AT delorie DOT com Date: Fri, 16 Jan 1998 20:04:07 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Malloc problem Precedence: bulk Hi, I'm writing a tile-based mapping system, and I've come up with a bit of a problem: I'm using layers for my maps, and when I try to access the layers (after they've been allocated with malloc), I get a page fault. Here's some code to (hopefully) make it easier to understand: typedef struct { short* data; } LAYER; typedef struct { short width, height; short num_layers; LAYER* layers; } TMap; Then I allocate it like this (map is of type TMap): if (!(map.layers = (LAYER*)malloc(sizeof(LAYER) * map.num_layers))) { allegro_exit(); printf("Error allocating memory for layers!\n"); exit(-1); } for (i=0; i