'Watcom C Library reference'에 해당되는 글 62건

  1. 2021.08.03 Watcom C Library : _memmax, memmove, _fmemmove, memset, _fmemset, min, mkdir, MK_FP

 

 

Watcom C Library Reference : _memmax, memmove, _fmemmove, memset, _fmemset, min, mkdir, MK_FP

 

 

 

 

_memmax

 

Synopsis : #include <malloc.h> 

              size_t _memmax( void );

 


Description : The _memmax function returns the size of the largest contiguous block of memory available for dynamic memory allocation in the near heap (the default data segment). In the tiny, small and medium memory models, the default data segment is only extended as needed to satisfy requests for memory allocation. Therefore, you will need to call _nheapgrow in these memory models before calling _memmax in order to get a meaningful result.

 

 

Returns : The _memmax function returns the size of the largest contiguous block of memory available for dynamic memory allocation in the near heap. If 0 is returned, then there is no more memory available in the near heap.

 

 

See Also : calloc, _freect, _memavl, _heapgrow, malloc

 


Example :

#include <stdio.h> 

#include <malloc.h>


void main( )

{
    char     *p;

    size_t    size;


    size = _memmax( );

    printf( "Maximum memory available is %u\n", size );

    _nheapgrow( );

    size = _memmax( );

    printf( "Maximum memory available is %u\n", size );

    p = (char *) _nmalloc( size );

    size = _memmax( );

    printf( "Maximum memory available is %u\n", size );

}

 


produces the following :
Maximum memory available is 0 

Maximum memory available is 62700 

Maximum memory available is 0 

 

Classification : WATCOM
Systems : All

 

 

 

 

 

memmove, _fmemmove

 

Synopsis : #include <string.h> 

              void *memmove( void *dst, const void *src, size_t length); 

              void __far *_fmemmove( void __far *dst, const void __far *src, size_t length );


Description : The memmove and _fmemmove functions copy length characters from the buffer pointed to by src to the buffer pointed to by dst. Copying of overlapping objects will take place properly. See the memcpy or _fmemcpy functions to copy objects that do not overlap.


The _fmemmove function is a data model independent form of the memmove function. It accepts far pointer arguments and returns a far pointer. It is most useful in mixed memory model applications.

 

 

Returns : The memmove and _fmemmove functions return dst.

 

 

See Also : memcpy, memset

 


Example :

#include <string.h>


void main( )

{
    char     buffer[80];
   

    memmove( buffer+1, buffer, 79 );

    buffer[0] = '*';
}

 

Classification : memmove is ANSI, _fmemmove is not ANSI
Systems : memmove - All

             _fmemmove - All

 

 

 

 

 

memset, _fmemset

 

Synopsis : #include <string.h> 

              void *memset( void *dst, int c, size_t length );

              void __far * _fmemset( void __far *dst, int c, size_t length );


Description : The memset and _fmemset functions fill the first length characters of the object pointed to by s with the value c.

 

The _fmemset function is a data model independent form of the memset function. It accepts far pointer arguments and returns a far pointer. It is most useful in mixed memory model applications.

 

 

Returns : The memset and _fmemset functions return the pointer s.

 

 

See Also : memchr, memcmp, memcpy, memmove

 


Example :

#include <string.h>


void main( )

{
    char     buffer[80];

 

    memset( buffer, '=', 80 );

}

 

Classification : memset is ANSI, _fmemset is not ANSI
Systems : memset - All

             _fmemset - All

 

 

 

 

 

min

 

Synopsis : #include <stdlib.h> 

              #define min(a, b) (( (a) < (b) ) ? (a) : (b) )

 


Description : The min macro will evaluate to be the lesser of two values. It is implemented as follows.
                 #define min(a, b) (( (a) < (b) ) ? (a) : (b) )

 

 

Returns : The min macro will evaluate to the smaller of the two values passed.

 

 

See Also : max

 


Example :

#include <stdio.h> 

#include <stdlib.h>


void main( )

{
    int     a;


    /*  The following line will set the variable "a" to 1 * since 10 is greater than 1.   */

    a = min( 1, 10 ); 

    printf( "The value is : %d\n", a );

}

 

Classification : WATCOM
Systems : All

 

 

 

 

 

mkdir

 

Synopsis : #include <sys\types.h> 

              #include <direct.h>

              int mkdir( const char *path );

 


Description : The mkdir function creates a new subdirectory with name path. The path can be either relative to the current working directory or it can be an absolute path name.

 

 

Returns : The mkdir function returns zero if successful, and a non-zero value otherwise.

 

 

Errors : When an error has occurred, errno contains a value indicating the type of error that has been detected.

 Constant  Meaning
 EACCES  Search permission is denied for a component of path or write permission is denied on the parent directory of the directory to be created.
 ENOENT  The specified path does not exist or path is an empty string.

 

 

See Also : chdir, chmod, getcwd, rmdir, stat, umask

 


Example :

To make a new directory called \watcom on drive C:


#include <sys\types.h> 

#include <direct.h>


void main( )

{
    mkdir( "C:\\watcom" );

}


Note the use of two adjacent backslash characters(\) within character-string constants to signify a single backslash.

 

Classification : POSIX 1003.1
Systems : All

 

 

 

 

 

 

 

MK_FP

 

Synopsis : #include <i86.h> 

              void __far *MK_FP( unsigned int segment, unsigned int offset );


Description : The MK_FP macro can be used to obtain the far pointer value given by the segment segment
value and the offset offset value. These values may be obtained by using the FP_SEG and FP_OFF macros.

 

 

Returns : The MK_FP macro returns a far pointer.

 

 

See Also : FP_OFF, FP_SEG, segread

 


Example :

#include <i86.h> 

#include <stdio.h>


void main( )

{
    unsigned short __far *bios_prtr_port_1;


    bios_prtr_port_1 = (unsigned short __far *) MK_FP( 0x40, 0x8 );

    printf( "Port address is %x\n", *bios_prtr_port_1 );

}

 

Classification : Intel
Systems : MACRO

 

 

 

 

 

 

 

 

This manual describes the WATCOM C library for DOS, Windows, and OS/2, It includes the Standard C Library (as defined in the ANSI C Standard).

 

WATCOM C Language Reference manual describes the ANSI C Programming language and extensions to it which are supported by WATCOM C/C++ (32bit)

 

 

 

728x90
반응형
Posted by 전화카드
,