gomer@spiff.soe.clarkson.edu (Paul Kronenwetter) (06/29/91)
I've dug through FAQ and couldn't find anything relating to this: I need to malloc space greater than 64k.. ie: char file; ... file=malloc(70000L) Granted the syntax for 70000L probably isn't correct just make believe it works.. ;-) The real problem is that I need both the space and to use the str??? functions.. as well as file[count]=fgetc(infile); assuming count is a long unsigned int > 0xffff... Does anyone see a way to do this or am I going to have to write my own routines (gasp) to do this sort of thing using far pointers & farmalloc... -Paul Paul Kronenwetter - N2KIQ |FM: 146.91 |Snail Mail: Box 6942, Potsdam, NY gomer@spiff.soe.clarkson.edu| 444.15 | 13699-6942 "The right half of the brain controls the left half of the body. This means that only left handed people are in their right mind." -- Paul Kronenwetter - N2KIQ |FM: 146.91 |Snail Mail: Box 6942, Potsdam, NY gomer@spiff.soe.clarkson.edu| 444.15 | 13699-6942 "The right half of the brain controls the left half of the body. This means that only left handed people are in their right mind."
grimlok@hubcap.clemson.edu (Mike Percy) (06/30/91)
gomer@spiff.soe.clarkson.edu (Paul Kronenwetter) writes: > file=malloc(70000L) >Granted the syntax for 70000L probably isn't correct just make believe it >works.. ;-) The real problem is that I need both the space and to use the >str??? functions.. as well as file[count]=fgetc(infile); assuming count is >a long unsigned int > 0xffff... Does anyone see a way to do this or am I >going to have to write my own routines (gasp) to do this sort of thing using >far pointers & farmalloc... Huh? Excuse me while I try to figure this out...you are aware of far pointers and far*alloc functions in TurboC(++), but you want to write your own functions to malloc > 64K? How about try: stuff far *file; file = (stuff far *)farmalloc(70000L); Actually, to acces >64K, you need to use huge rather than far: stuff huge *file; file = (stuff huge *)farmalloc(70000L); Now this will work... long i; for(i = 0; i < 70000L; i++) file[i] = /* whatever */; If this is too much try: #define malloc(x) farmalloc((x)) You'll still need to use huge pointer to acces it though. By the way, in large data memory models, malloc is fed by farmalloc anyway, esentially being this: void far *malloc(size_t size) { return farmalloc((long)size); } One last thing, when posting compiler-specific questions, which most often don't belong in c.l.c anyway, it's polite to put the compiler name in the subject line. This will let people skip messages that don't pertain to them. "I don't know about your brain, but mine is really...bossy." Mike Percy grimlok@hubcap.clemson.edu ISD, Clemson University mspercy@clemson.BITNET (803)656-3780 mspercy@clemson.clemson.edu