Article View: comp.os.msdos.programmer
Article #7609Help on Memory Manager
From: Brian Parkinson
Date: Tue, 12 Jan 1993 13:30
Date: Tue, 12 Jan 1993 13:30
34 lines
1539 bytes
1539 bytes
A general question (re memory management under DOS). If I allocate a pointer to 64K in Borland C. unsigned char *ptr = farmalloc(0xFFFF); The pointer has some segment, and the offset is always 4 (four). This means that the last few bytes of data are actually in the NEXT segment !! If the pointer is declared to be far, then these bytes roll to the bottom of the same segment. My question is twofold : (1) What does DOS do with these 4 extra bytes - are they used by the memory manager of DOS (or, in an even weirder scenario, is this a quirk of Borland C, and would not appear in Microsoft C) ??? (2) I need to have a 64K (EXACTLY) byte memory block in an application, and would like to be aligned from the base of the segment (i.e. an offset of 0 (zero) not 4 (four)), so if I just say "ptr-=4", the pointer will now be at the base of the segment, but..... is this inviting disaster ??? Does someone out there know the answers to this (what I consider to be a) quirk ? -- What's the point in callin' shots Brian Parkinson This cue ain't straight in line <parki@csri.toronto.edu.ca> The cue-ball's made of styrofoam And no-one's got the time
Technical Details
Message-ID:
<1993Jan12.083016.4726@jarvis.csri.toronto.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!utcsri!csri.toronto.edu!parkiShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!utcsri!csri.toronto.edu!parki Newsgroups: comp.os.msdos.programmer From: parki@csri.toronto.edu (Brian Parkinson) Subject: Help on Memory Manager Message-ID: <1993Jan12.083016.4726@jarvis.csri.toronto.edu> Organization: CSRI, University of Toronto Distribution: na Date: 12 Jan 93 13:30:16 GMT Lines: 35