From: dmt AT bigfoot DOT com (Jeff W./DMT) Newsgroups: comp.os.msdos.djgpp Subject: Allegro load_datafile(..) crashes Date: Mon, 30 Mar 1998 23:48:44 GMT Organization: ZipLink -- America's Hottest ISP Lines: 93 Message-ID: <35202d71.62791@news.ziplink.net> NNTP-Posting-Host: chi-ip-1-150.ziplink.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I've successfully used the load_datafile(filename) routine a number of times, however this time it's mysteriously crashing. I was able to figure out that a call to malloc(..) when creating the datafile pointer was the culprit each time. The only thing that I can think of that may cause this problem is that in my c++ program, I have the following set up: typedef struct BaseType { //base layer of tiles byte tileno; byte opaque; byte collision; byte flag; }; typedef struct FringeType //non-pickupable objects { byte tileno; byte flag; }; typedef struct ObjType //normal objects { byte tileno; byte active; //shouldit be blitted??? byte flag; }; typedef struct RoofType //for the roof of buildings/etc { byte tileno; byte flag; }; typedef struct MapStruct //just contains all the other structures into 1 { BaseType base; FringeType fringe; ObjType obj; RoofType roof; }; class MapClass { protected: MapStruct **Data; ... public: void Init(int nrows, ncols) ... }; the first thing my program does is to allocate memory for the Data array. I do this using the following code that I got out of the C++ FAQ: void MapClass::Init(int nrows, int ncols) { int total_cols[ncols]; Data = new MapStruct*[nrows]; for (int i=0; i < nrows; ++i) Data[i] = new MapStruct[ total_cols[i] ]; } if the above puzzles you (it puzzles me, but seemed to work), what I'm trying to do is at runtime, create an array of type MapStruct of size [nrows][ncols]. That looked like the most plausible way to me in the FAQ. Anyways, my point is, anytime I do: datfile = load_datafile("FILENAME"); my program crashes. Does the problem have something to do with my setup of the MapClass/Struct?? If so, can you suggest a solution, or at least tell me where to look?? Thanks. --Jeff W. "The finding of DMT in normal human body fluids opens up interesting moral and legal questions. Since DMT is illegal, as is 'any substance, compound or mixture' containing DMT, it would seem that we are all guilty of possesion of a controlled substance" -Jonathon Ott My weird, trippy page: http://www.geocities.com/SunsetStrip/Alley/3450/index.html