home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / msdos / programm / 12013 < prev    next >
Encoding:
Internet Message Format  |  1993-01-12  |  1.5 KB

  1. Path: sparky!uunet!utcsri!csri.toronto.edu!parki
  2. Newsgroups: comp.os.msdos.programmer
  3. From: parki@csri.toronto.edu (Brian Parkinson)
  4. Subject: Help on Memory Manager
  5. Message-ID: <1993Jan12.083016.4726@jarvis.csri.toronto.edu>
  6. Organization: CSRI, University of Toronto
  7. Distribution: na
  8. Date: 12 Jan 93 13:30:16 GMT
  9. Lines: 35
  10.  
  11. A general question (re memory management under DOS).
  12.  
  13. If I allocate a pointer to 64K in Borland C.
  14. unsigned char *ptr = farmalloc(0xFFFF);
  15.  
  16. The pointer has some segment, and the offset is always
  17. 4 (four).  This means that the last few bytes of data are
  18. actually in the NEXT segment !!  If the pointer is declared
  19. to be far, then these bytes roll to the bottom of the same
  20. segment.
  21.  
  22. My question is twofold :
  23.  
  24. (1)  What does DOS do with these 4 extra bytes - are they
  25. used by the memory manager of DOS (or, in an even weirder
  26. scenario, is this a quirk of Borland C, and would not appear
  27. in Microsoft C) ???
  28.  
  29. (2)  I need to have a 64K (EXACTLY) byte memory block in an
  30. application, and would like to be aligned from the base of
  31. the segment (i.e. an offset of 0 (zero) not 4 (four)), so
  32. if I just say "ptr-=4", the pointer will now be at the base
  33. of the segment, but..... is this inviting disaster ???
  34.  
  35. Does someone out there know the answers to this (what I
  36. consider to be a) quirk ?
  37.  
  38.  
  39.  
  40. -- 
  41.                     What's the point in callin' shots
  42. Brian Parkinson                This cue ain't straight in line
  43. <parki@csri.toronto.edu.ca>        The cue-ball's made of styrofoam
  44.                     And no-one's got the time
  45.  
  46.