Xref: utzoo comp.databases:5804 comp.lang.c:28432 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!snorkelwacker!bu.edu!m2c!wpi!jhallen From: jhallen@wpi.wpi.edu (Joseph H Allen) Newsgroups: comp.databases,comp.lang.c Subject: Re: farrealloc() bug in Turbo C Keywords: fix needed Message-ID: <12640@wpi.wpi.edu> Date: 4 May 90 09:25:23 GMT References: <6377@vax1.acs.udel.EDU> <1990May4.003455.1602@egsner.cirr.com> Reply-To: jhallen@wpi.wpi.edu (Joseph H Allen) Distribution: usa Organization: Worcester Polytechnic Institute, Worcester ,MA Lines: 52 In article <1990May4.003455.1602@egsner.cirr.com> clifton@egsner.cirr.com (Clifton Bean) writes: >In article <6377@vax1.acs.udel.EDU> ray@vax1.acs.udel.EDU (Thomas Ray) writes: >> The function farrealloc() in Turbo C is described as ``Adjusts allocated >>block in far heap.... Blocks larger than 64K can be allocated''. The >>problem is that it only works for blocks of up to 64K. I called their >> So, does anyone have a piece of code that can do a farrealloc() in >>Turbo C, or can anyone write and test such a function? It would be nice You might consider using the MS-DOS memory allocator: #include void far *falloc(unsigned long size) { void far *block=0; if(0xfff00000&size) return 0; _BX=size&15?size/16+1:size/16; _AH=0x48; geninterrupt(0x21); __emit__(0x73,2,0x28,0xc0); /* Clear AX if Carry is set */ *(1+(unsigned *)&block)=_AX; return block; } void ffree(void far *block) { _ES=FP_SEG(block); _AH=0x49; geninterrupt(0x21); } void far *frealloc(void far *block,unsigned long size) { if(0xfff00000&size) return 0; _ES=FP_SEG(block); _BX=size&15?size/16+1:size/16; _AH=0x4a; geninterrupt(0x21); __emit__(0x73,2,0x28,0xc0); /* Clear AX if Carry is set */ *(1+(unsigned *)&block)=_AX; return block; } Be forewarned, however: These are not compatible with turbo C's farm functions. Also, presumably MS-DOS is slower than turbo C, so only use these if you're not allocating very often. Also, these have only been tested in small & tiny models. -- jhallen@wpi.wpi.edu (130.215.24.1)