This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/allocmem.c

28 lines
676 B
C
Raw Permalink Normal View History

#include <stdio.h>
#include <dos.h>
void main( void )
{
#if defined(__NT__) || \
( defined(__OS2__) && \
(defined(__386__) || defined(__PPC__)) )
void *segment;
#else
unsigned segment;
#endif
/* Try to allocate 100 paragraphs, then free them */
if( _dos_allocmem( 100, &segment ) != 0 ) {
printf( "_dos_allocmem failed\n" );
printf( "Only %u paragraphs available\n",
segment );
} else {
printf( "_dos_allocmem succeeded\n" );
if( _dos_freemem( segment ) != 0 ) {
printf( "_dos_freemem failed\n" );
} else {
printf( "_dos_freemem succeeded\n" );
}
}
}