iofunc_ocb_calloc()

Allocate an iofunc Open Control Block

Synopsis:

#include <sys/iofunc.h>

iofunc_ocb_t * iofunc_ocb_calloc( 
                     resmgr_context_t * ctp,
                     iofunc_attr_t * attr );

Arguments:

ctp
A pointer to a resmgr_context_t structure that the resource-manager library uses to pass context information between functions.
attr
A pointer to a iofunc_attr_t structure that defines the characteristics of the device that the resource manager handles.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The iofunc_ocb_calloc() function allocates an iofunc OCB. It has a number of uses:

Note: You should fill in the attribute's mount structure (i.e., the attr->mount pointer) instead of replacing this function.

If you specify ocb_calloc and ocb_free callouts in the attribute's mount structure, then you should use the callouts instead of calling the standard iofunc_ocb_calloc() and iofunc_ocb_free() functions.

Returns:

A pointer to an iofunc_ocb_t OCB structure, or NULL if an error occurred (errno is set).

Errors:

ENFILE
There are too many open files in the system. For iofunc_ocb_calloc(), this happens if there isn't enough memory to allocate the OCB; if you override this function, your replacement might place further restrictions on the number of OCBs.

Examples:

Override iofunc_ocb_calloc() and iofunc_ocb_free() to manage an extended OCB:

typedef struct
{
    iofunc_ocb_t    iofuncOCB; /* the OCB used by iofunc_* */
    int             myFlags;
    char            moreOfMyStuff;
}   MyOCBT;

MyOCBT *iofunc_ocb_calloc (resmgr_context_t *ctp, 
                           iofunc_attr_t *attr)
{
    return ((MyOCBT *) calloc (1, sizeof (MyOCBT));
}

void iofunc_ocb_free (MyOCBT *ocb)
{
    free (ocb);
}

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes