[Previous]
[Contents]
[Next]

qnx_segment_free()

unlink a segment from a process

Synopsis:

#include <sys/seginfo.h>
int qnx_segment_free( unsigned segment );

Description:

The qnx_segment_free() function unlinks the segment segment from the currently running process. If the link count goes to zero, the memory is returned to the system. Each call to qnx_segment_get() or qnx_segment_put() increases the link count by one.

If you unlink a segment allocated using qnx_segment_overlay(), the memory isn't returned to the system.

Returns:

0
Success
-1
An error occurred. errno is set to indicate the error.

Errors:

EINVAL
The segment doesn't exist.

Examples:

#include <i86.h>
#include <sys/seginfo.h>

void main()
  {
    unsigned base;
    char __far *p;

    /* Allocate a 32 Kbyte array */
    base = qnx_segment_alloc( 32768 );

    /* Point at byte 16,000 in the array */
    p = MK_FP( base, 16000 );

    /* Set the byte and read it back */
    *p = 'a';
    printf( "base = %u, p = %08lx\n", base, p );
    printf( "*p = %c\n", *p );
    qnx_segment_free( base );
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

errno, qnx_segment_alloc(), qnx_segment_alloc_flags(), qnx_segment_arm(), qnx_segment_flags(), qnx_segment_get(), qnx_segment_huge(), qnx_segment_index(), qnx_segment_info(), qnx_segment_overlay_flags(), qnx_segment_overlay(), qnx_segment_put(), qnx_segment_raw_alloc(), qnx_segment_raw_free(), qnx_segment_realloc()


[Previous]
[Contents]
[Next]