Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

ctThrdBlockInit

Initialize memory for a thread block.

Short Name

ctThrdBlockInit()

Type

Threading function

Declaration

NINT ctThrdBlockInit(pctBLOCK block)

Description

ctThrdBlockInit() provides a means to initialize block. Before using a block the memory for the block must be cleared. If this space is initialized when allocated, this function is not needed.

However, if the block memory requires “zeroing out”, this function provides a convenient way to perform this task. This is most common when a block is defined on the stack within an application. In essence, this function simply initializes (memset()) the memory.

Return

ctThrdBlockInit() always returns NO_ERROR. See FairCom DB Error Codes for a complete listing of valid FairCom DB error values.

Example

NINT err; /* ctThrdInit return code. */

ctBLOCK guiblk; /* Block to wait for window creation. */

ctMUTEX tfin_mtx; /* Mutex for thread finished counter. */


#if (defined(USE_CURSES) || defined(USE_ANSI))

ctMUTEX tprt_mtx; /* Mutex for displaying thread output.*/

#endif /* USE_CURSES || USE_ANSI */


if ((err = ctThrdInit(3,(LONG) 0, (pctINIT)&cfg))) {

ctrt_printf("\nctThrdInit failed. Error={%d}\n", err);

ctrt_exit(1);

}


/* Initialize Blocks and Mutexes. */

ctThrdBlockInit(&guiblk);

ctThrdMutexInit(&tfin_mtx);


#if (defined(USE_CURSES) || defined(USE_ANSI))

ctThrdMutexInit(&tprt_mtx);

#endif /* USE_CURSES || USE_ANSI */

See also

ctThrdMutexInit

TOCIndex