Path: utzoo!mnetor!uunet!husc6!hao!ames!sdcsvax!ucsdhub!sdsu!gold From: gold@sdsu.UUCP (Dan Gold) Newsgroups: comp.unix.xenix Subject: memory allocation i.e. malloc Message-ID: <2866@sdsu.UUCP> Date: 15 Dec 87 16:13:16 GMT Organization: San Diego State University, Math/Sciences Dept. Lines: 40 Keywords: malloc memory allocation core dump segment violation I having a problem allocating memory with malloc. It's running on an Zenith 248 w/ SCO 2.1.3 O.S., and 2.1 develop. sys ( me thinks). Machine has 3Mb RAM. the problem is malloc returns negative when the address is > 32K. I tried the following code: #includestruct message { char foo[260]; } *msgs[900]; main() { int i; for (i=0;i < 900;i++) { msg[i]=(struct message *)malloc(sizeof(struct message)); printf("i= %d, msg[i] = %ld\n",i,msg[i]); } } malloc returns up to 326xx fine, then turns over and I get -32xxx. I've compiled the code with "cc -M2e" and the memory model flag, either large or huge. I've tried both, used various combos of "far" in places, nothing seems to work. I know the memory isn't linear addressing, but I don't think a valid pointer is too much to ask. I also know the O.S and compiler may be behind, but this we're going to get a 386 (sometime soon, prob. w/SCO 386), and don't want to update if we're not going to need it. (OR esp if it won't help.) I called SCO and the software support basically said get the latest update, there were some bug fixes. Were they relevant to this? In the meantime, anyone got any ideas ? thanx, Dan UUCP: {...sdcsvax,ucsdhub}!sdsu!gold ARPA:(almost) : sdsu!gold@sdcsvax Disclaimer: Real microprocessors don't do segmentation.