Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!rochester!rit!ultb!ritcsh!sabin!bjm From: bjm@sabin.UUCP (Brendan J. McMahon) Newsgroups: comp.lang.c Subject: Malloc Trouble with Large Memory Model Message-ID: <208@sabin.UUCP> Date: 19 Apr 89 19:42:35 GMT Reply-To: bjm@sabin.UUCP (Brendan J. McMahon) Organization: Sabin Metal Corp., Scottsville, NY Lines: 43 We have never had any need for any memory module other than the default small. We are switching to a new machine (intel 386 ) and our database libraries (informix) only came in the large model. So all programs that use these have to be compiled with -Ml2 (large model 286). (Or do they?) Jist of a Problem: struct labelrec{ int blah; . . }; struct labelrec *lrec[20]; lrec[0]=(struct labelrec *)malloc(sizeof(struct labelrec)); Compile Message: Warning: cast of int expression to far pointer Run time problems: Printf(sizeof(struct labelrec)) = Some huge number It should be around 64. So it looks like it has put the lrec pointers into a seperate data segment, but the int return value from malloc does not give lrec[0] the large full address (segment:offset pair) needed to access this data. I am not familiar with memory modules, so many attempts to throw in near/far keywords around different definitions did no good. Thanks for any help! -- Brendan J. McMahon Sabin Metal Corp. | Refiners of Precious Metals | Hardware Trouble? Scottsville, NY | ****** Au Ag Pt Pd Rh ****** | Give us a call, we'll 716-538-2194 |lazlo!sabin!bjm || ritcsh!sabin!bjm| melt your trouble away