Skip to Main Content
  • Questions
  • OCIAttrSet with another Hanlde as value

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Andrey.

Asked: March 22, 2022 - 9:10 am UTC

Last updated: April 20, 2022 - 4:35 am UTC

Version: 19c

Viewed 1000+ times

You Asked

Hello,

I've tried to find exact description in Docu but didn't succeed. How does OCIAttrSet process values passed as pointers? In particular, when the value is another handle? Example:

    OCIAuthInfo *authp;
    status = OCIHandleAlloc(envhp, &authp, OCI_HTYPE_AUTHINFO);
    status = OCIAttrSet(authp, OCI_HTYPE_AUTHINFO, driver_name, driver_name_len, OCI_ATTR_DRIVER_NAME, errhp);
    status = OCIAttrSet(poolhp, OCI_HTYPE_SPOOL, authp, 0, OCI_ATTR_SPOOL_AUTH, errhp);


Here, driver_name is char*. I assume the string is copied, so I can free(driver_name). But what about authp? Is it copied, or only pointer is stored? Should I call OCIHandleFree(authp), or shall that be done by OCI, when poolhp is freed?

and Connor said...

I asked a couple of internals folks:

both attribute values seem to be copied.

and

Any handle allocated by the OCIHandleAlloc() function should ideally be freed by OCIHandleFree() function call separately.

In this case, authp is the authentication handle and should be freed using OCIHandleFree() function as follows:
if (authp)

(void) OCIHandleFree((dvoid *) authp, (ub4) OCI_HTYPE_AUTHINFO);


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database