malloc & tc.

florin coter ssreefc at techunix.BITNET
Thu May 11 16:08:17 AEST 1989


        hello world,
        this is a second posting about malloc. thanks to all who answered.
from the answers i got it is clear to me that it was some missunderstanding.
i'll try this time to be clearer.
THE CODE:

        ....

        extern char a[1000][50];        /* !!! */

        main()
        {
                char *malloc(), *p;

                if( ( *p=malloc( (unsigned)30000 ) ) == NULL )
                        puuts( "no space" );

                ...
        }
        ...
i use turboC 1.5.
in TINY model all one can get is 64K (code, data,...). from the above
it is more than obvious that the request of 30K of space cannot be
satisfied. still malloc does not complain and i get data written over
data. the above is still true for SMALL model where you get 64K for all
data which is more than 64K. still no complain from malloc.
i use microsoft C 3.1.
small model is the same as tc and the program behaves the same way.
WHYYYYYYYYYYYYYYYYYYYY ???????????????????????
florin.

--------
Florin Coter          ssreefc at techunix
Home address:         40/37 Leon Blum St., Haifa, Israel.
Home phone:           04-386133.
Office address:       Solid State Institute, Technion, Haifa 3200, Israel.
Office phone:         04-293938/293613/293615.



More information about the Comp.lang.c mailing list