MSC 6.0 malloc question

Kevin D. Quitt kdq at demott.COM
Tue Jun 5 10:44:37 AEST 1990


In article <36163 at sequent.UUCP> brett at sequent.UUCP (Brett Leichner) writes:
>
>I'm writing a part C/part assembly routine that needs to be able to allocate and
>use a full segment (65535 bytes).  Here are the specifics:
>
>The problem is that if "num_bytes" is greater than about 65550 then _fmalloc
>returns null trying to allocate the first buffer.

>1.  Does DOS use these extra bytes for house-keeping?

    When DOS allocates memory, it requires 1 paragraph (16 bytes out of your
63356 (not 65535) bytes.



>2.  Is it possible to allocate all 65535 bytes of a segment for use? (dynamic
>    allocation only).

    Yes - declare your pointer as huge or use the huge model to compile


>3.  If DOS needs some of the memory for house-keeping, is it possible to
>    use the huge model, and allocate say 66000 bytes in such a way that the
>    house-keeping stuff will be pushed over into another segment thereby
>    giving me at least one full segment?

    Every paragraph in DOS starts a new segment, so the DOS house-keeping
will be at NNNm:0 and your memory will be at NNNn:0 where n = m + 1

>4.  On a side note, using the hugh model and declaring arrays that span multiple
>    segments is there a way to guarantee that the array will be composed of
>    segments physically adjacent?

    It shouldn't matter in the huge model - the compiler does all the extra
work for you. (can you say slow? I knew you could).


-- 
 _
Kevin D. Quitt         Manager, Software Development    34 12 N  118 27 W
DeMott Electronics Co. 14707 Keswick St.   Van Nuys, CA 91405-1266
VOICE (818) 988-4975   FAX (818) 997-1190  
MODEM (818) 997-4496 Telebit PEP last      demott!kdq   kdq at demott.com

      96.37% of the statistics used in arguments are made up.



More information about the Comp.lang.c mailing list