1 Reply Latest reply: Aug 17, 2012 12:27 PM by Steve.Clamage-Oracle RSS

    OCIAttrGet - Should we free the memory allocated to the out variable

    user12559680
      In the below code, the application is crashing @ free(svcname).
      What is the issue here? should we delete the out variable or not?

      {
      char* svcname;

      if (OCIAttrGet(eventhp, (ub4) OCI_HTYPE_EVENT, (dvoid *) &svcname, (ub4 *) &sizep, OCI_ATTR_SERVICENAME, dm_infop->errhp) != OCI_SUCCESS) {
      pinlog(PIN_FILE_SOURCE_ID, __LINE__, LOG_FLAG_ERROR, " Unable to get service name.\n");
      return;
      }

      free(svcname);
      }

      -Shiva
        • 1. Re: OCIAttrGet - Should we free the memory allocated to the out variable
          Steve.Clamage-Oracle
          This forum is about using Studio compilers, and general questions about C, C++, and Fortran.
          Your question appears to be specifically about the programming interface to the Oracle database, and more specifically about who owns the memory returned by an OCI call.
          You are more likely to get a helpful answer in a database programming forum.

          If you are using OCCI (I can't tell from the sample), try the OCCI forum:
          C++ Call Interface (OCCI)

          Otherwise, select one of the database forums that seems most closely related to what you are doing:
          https://forums.oracle.com/forums/category.jspa?categoryID=18