Deallocates a context structure.
CS_RETCODE cs_ctx_drop(context); cs_context *context;
(I) A pointer to a context structure.
cs_ctx_drop returns one of the following values:
Value |
Meaning |
---|---|
CS_SUCCEED (-1) |
The routine completed successfully. |
CS_FAIL (-2) |
The routine failed. The most common cause for a cs_ctx_drop failure is that the context contains an open connection. |
The following code fragment demonstrates how to use cs_ctx_drop with other functions at the end of a program to close the connection and return to CICS. It is taken from the sample program SYCTSAA6 in Appendix A, “Sample Language Application.”
/********************************************************************/ /* */ /* Subroutine to perform drop command handler, close server */ /* connection, and deallocate Connection Handler. */ /* */ /********************************************************************/ void close_connection () { CS_INT rc;
/*------------------------------------------------------------------*/ /* drop the command handle */ /*------------------------------------------------------------------*/ rc = ct_cmd_drop (cmd); if (rc == CS_FAIL) { strncpy (msgstr, "CT_CMD_DROP failed", msg_size); error_out (rc) ; }
/*------------------------------------------------------------------*/ /* close the server connection */ /*------------------------------------------------------------------*/ rc = ct_close (connection, (long) CS_UNUSED); if (rc == CS_FAIL) { strncpy (msgstr, "CT_CLOSE failed", msg_size); error_out (rc) ; } /*------------------------------------------------------------------*/ /* De_allocate the connection handle */ /*------------------------------------------------------------------*/ rc = ct_con_drop (connection); if (rc == CS_FAIL) { strncpy (msgstr, "CT_CON_DROP failed", msg_size); error_out (rc) ; } } /* end close_connection */
/********************************************************************/ /* */ /* Subroutine to perform exit client library and deallocate context */ /* structure. */ /* */ /********************************************************************/ void quit_client_library () { CS_INT rc; /*------------------------------------------------------------------*/ /* Exit the Client Library */ /*------------------------------------------------------------------*/ rc = ct_exit (context, (long) CS_UNUSED); if (rc == CS_FAIL) { strncpy (msgstr, "CT_EXIT failed", msg_size); error_out(rc) ; } /*------------------------------------------------------------------*/ /* De-allocate the context structure */ /*------------------------------------------------------------------*/ rc = cs_ctx_drop (context); if (rc == CS_FAIL) { strncpy (msgstr, "CT_CTX_DROP failed", msg_size); error_out(rc) ; } EXEC CICS RETURN ; } /* end quit_client_library */
cs_ctx_drop deallocates a context structure.
A context structure describes a particular context, or operating environment, for a set of server connections.
After a context deallocates, it cannot be reused. To allocate a new context, an application calls cs_ctx_alloc.
A Client-Library application cannot call cs_ctx_drop to deallocate a context structure until it calls ct_exit to clean up Client-Library space associated with the context.
cs_ctx_drop fails if the context contains an open connection.
Related functions