Path: utzoo!attcan!uunet!munnari!murdu!strasser From: strasser@murdu.OZ (Mike Strasser) Newsgroups: comp.sys.mac.programmer Subject: Help with port to LSC of command line-driven program Keywords: Quick fix before I re-write it into a real Mac program Message-ID: <1426@murdu.OZ> Date: 8 Aug 88 08:02:55 GMT Reply-To: strasser@munnari.UUCP (Mike Strasser) Organization: Forestry Section, University of Melbourne Lines: 58 I'm new to programming Macs and have a program in C which has run successfully on PCs, VAXes and a Unix machine (so I know it works). It's a forest growth simulation model for which I've written a nifty command line interface using scanf(). I want to eventually re-write the program to run on Macs to be used for my own research and for teaching, but before that I want to get it going in a "quick-and-dirty" fashion first (for other reasons). We have LSC 2.15 (soon to order 3.0) and 3/5 of IM (I'm waiting for the bookshop to get new stocks of vols I & III). I've read of people running their programs under LSC without problems, but I appear to be unlucky. When I try to run the program I get nowhere because it can't even read the first file properly before it either stops with a spurious error or bombs. I don't know enough 68k asm to understand Macsbug. The routine which bombs is being called from another through one of these structures: typedef struct { char Name[9]; void (*FuncPtr)(); } FuncVar; (there's an array of them). Each associates a name with a function pointer so that the user types the name of the function and it gets called, thus: (*Funcs[i].FuncPtr)(); (where Funcs is the aforementioned array). Could this be the problem? The offending function is essential before anything else is done with the model. This function reads numbers from file using fscanf() into members of structures which belong to a linked list whose storage is handled by malloc() and free(). Should I do anything else about memory allocation on a Mac (short of re-writing quite a bit of code). Perhaps the problem is with memory allocation. What about program segmentation? Do I need to have particular functions in the same segment? All functions pointed to in the array Funcs (and the calling function) are in the same segment. Does need to be there too (it's huge: 18+ K)? Can someone please give me some ideas, or tell me what other information I need to provide? I have nothing to go on at the moment. The whole program is c. 3000 lines of code, but I could mail bits of it if necessary. --------------------------------------------------------------------------- Mike Strasser ACSnet, CSnet: strasser@murdu.oz Internet: strasser%murdu.oz@uunet.uu.net Forestry Section University of Melbourne Creswick, Victoria. 3363 Phone: (053) 45 2405 A u s t r a l i a +61 53 45 2405 ---------------------------------------------------------------------------