ssreefc@techunix.BITNET (florin coter) (05/08/89)
hello world,
this is the code
void main()
{
void *malloc( .... );
char *p;
if( ( p = (char *)malloc( many mega bytes... ) ) == NULL )
puts( "no space..." );
}
well, the use of the code is not relevant here. what is relevant
is the fact that i run it on an ibm with 640 Kb of ram. i compile with
turboC 1.5. it never complaines, but i never get the "no space..."
line on the screen. why ?
please email.
thanx, florin.
--------
Florin Coter ssreefc@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.
wietse@wzv.UUCP (Wietse Z. Venema) (05/11/89)
In article <8262@techunix.BITNET> ssreefc@techunix.BITNET (florin coter) writes: > > if( ( p = (char *)malloc( many mega bytes... ) ) == NULL ) > puts( "no space..." ); > >[on an ibm with 640 Kb of ram with turboC 1.5] i never get the "no space..." >line on the screen. why ? malloc() expects an unsigned integer argument. Therefore, on a 16-bit machine it allocates at most 65535 bytes per call. In your case, the argument as seen by malloc was 16 bits of gargabe. -- work: wswietse@eutrc3.uucp | Eindhoven University of Technology work: wswietse@heitue5.bitnet | Mathematics and Computing Science home: wietse@wzv.uucp | Eindhoven, The Netherlands