C Language Development Kit/Functions/CoreLeft2
From OptiWiki
< C Language Development Kit | Functions(Redirected from C Language Development Kit/Functions/coreleft2)
| Description | This function returns the amount of free space on the specified drive. | ||||||||||||||||||||
| Syntax | int coreleft2(unsigned char drive, unsigned long * space); | ||||||||||||||||||||
| Arguments | Specifies the drive. The following constants are defined for this:
unsigned char drive
Specifies the drive. The following constants are defined for this:
unsigned long * space
| ||||||||||||||||||||
| Returns | OK on success, or a negative integer on error. | ||||||||||||||||||||
| Remarks | The RAM disk shares space with the heap.
It is possible that malloc() returns NULL on a request for a smaller amount of memory then coreleft2(DRIVE_A,&size) reports. This occurs when the reported memory does not consist out of one block, but out of several smaller blocks. malloc() needs a single contiguous block of memory. | ||||||||||||||||||||
| Example | #include <stdio.h> #include <stdlib.h> #include "lib.h" void main( void ) { char data[20+1]; unsigned long size; FILE *fp; while( 1 ) { coreleft2(DRIVE_A,)); printf("\f1: mem = %lu", size); malloc(70000); while( getchar() == EOF ) idle(); coreleft2(DRIVE_A,)); printf("\f2: mem = %lu", size); if( NULL != ( fp = fopen("TEST.DAT", "wb"))) { fwrite( data, 1, 20, fp); fclose(fp); } while( getchar() == EOF ) idle(); coreleft2(DRIVE_A,)); printf("\f3: mem = %lu", size); format(); while( getchar() == EOF ) idle(); coreleft2(DRIVE_A,)); printf("\f4: mem = %lu", size); while( getchar() == EOF ) idle(); } } |
