pointers in C

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harisrinu
    New Member
    • Sep 2007
    • 3

    pointers in C

    what is the difference b/w near and huge pointer??

    what is a NULL macro??
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by harisrinu
    what is the difference b/w near and huge pointer??
    It's mainly an Intel-ism: a near pointer can point to something relative to a
    'current' position and has a span of 64K bytes, i.e. it can point to a range of
    memory <= 64KB. A huge pointer can point anywhere in memory.

    The notion of near and huge pointers is not part of the C ISO Standard.

    Originally posted by harisrinu
    what is a NULL macro??
    It's a macro named 'NULL'; there are two accepted definitions (the first one
    is the prefered one).

    [code=c]
    #define NULL ((void*)0)
    #define NULL 0
    [/code]

    kind regards,

    Jos

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Originally posted by JosAH
      It's mainly an Intel-ism: a near pointer can point to something relative to a
      'current' position and has a span of 64K bytes, i.e. it can point to a range of
      memory <= 64KB. A huge pointer can point anywhere in memory.
      More info. These are holdovers from the days of segmented memory models. Back when machines only had 1M memory model and 640K of that was for the user. Code was brought in from disc in 64K segments. If your pointer was to an object within the 64K it was a near pointer. Otherwise, it was a far pointer.

      You had to keep in mind how your code was written since a far pointer could be a swap of memory segments meaning 64k of memory may have to be brought in just to service the pointer. This translated to a slowdown in execution time.

      There was a "model" to describe the target machine: tiny, compact, huge, gigantic.


      These notions have disappeared with flat address spaces.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Even more info: Microsoft came to the C Standard in those days, wanting to make
        the 'bounded' pointer (read: near or small pointer) part of the Standard. I was a
        non voting member of the committee in these days and we laughed wholeheartedly
        at the ludicrous idea until they ran away.

        kind regards,

        Jos ;-)

        Comment

        Working...