RE: [Dev-C++] new is a wrapper around malloc so...
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel G. <sp...@ho...> - 2003-07-15 19:00:06
|
Thanks. I'm trying to use the large memory model at the moment but it hasn't gotten rid of the need for FAR. Maybe I've done something wrong somewhere, I need to check. Windows 9x has 16 bit code in it in places, such as Printer Drivers and other bits. >From: "Abhijit Shylanath" <mu...@gm...> >To: "Ioannis Vranos" ><iv...@em...>,<dev...@li...>,<sp...@ho...> >Subject: RE: [Dev-C++] new is a wrapper around malloc so... >Date: Wed, 16 Jul 2003 00:07:20 +0530 > > >Hello, Ioannis and Daniel. > > > I do not know what a Far pointer, but I do know that they exist. Can you > > tell us what does it mean? > >Well, you must know that we have four basic segments (on the 8086) - the >CS, >DS, SS and ES... by default, when a data pointer is defined, it is assumed >that the pointer resides in the data segment, and when a function pointer >is >defined, that it resides in the code segment. However, when a pointer is >flagged as `far', it means that the segment is also stored explicitly along >with the offset. So, basically, far pointers allow you to access the whole >(and overwhelmingly huge) 1M of the 8086. Basically, far means residing in >a >different segment, while near means residing in the same (the default) >segment. > >Daniel, in response to your original question: > >Assuming you code in Turbo-C++, you have three options: > >1. Use a memory-model in which the required pointer's type is far by >default. If you need far data (the most common), use compact (in which the >data pointers are still near). If you need far code, use (umm, not sure, >really) large or huge (check the docs). You'll need to say something like >this: > char *foo = (char *)malloc(WHATEVER); > >2. Use the farmalloc() function (in TC - in M$C, I've heard that it's named >halloc()). Corresponding frees should be done by farfree() (dunno about >M$C). > > char far *foo = (char far *)farmalloc(WHATEVER); > // ... > farfree(foo); > >3. The easiest - simply call `new'. AFAIK, you don't need to overload new: > > char far *big_one = new char far[200]; > // ^? > // Play around a bit with the syntax, I'm not sure that this works... > > I remember doing something like this sometime back. > >However, why do you need to use different segments at all? You should try >porting it to 32-bit protected-mode DOS (or even Windows console-mode), if >your application allows it. Sad as it is for me to say it, DOS is dead. >Anyway, here are a few links you might find interesting: > >* http://www.delorie.com/djgpp > DJGPP - A DOS protected-mode C/++ compiler based on GCC > >* http://sunsite.lanet.lv/ftp/mirror/x2ftp/msdos/programming/ > The X2FTP - hordes of information on related topics. > >HTH. > >-- >Abhijit Shylanath >Homepage: http://mudeth.tripod.com/ > > > > >------------------------------------------------------- >This SF.Net email sponsored by: Parasoft >Error proof Web apps, automate testing & more. >Download & eval WebKing and get a free book. >www.parasoft.com/bulletproofapps1 >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users _________________________________________________________________ Sign-up for a FREE BT Broadband connection today! http://www.msn.co.uk/specials/btbroadband |