[Info-ingres] OpenAPI and valgrind
Martin Bowes
martin.bowes at ndph.ox.ac.uk
Wed Apr 25 13:24:03 UTC 2018
Hi All,
I have a routine using OpenAPI which according to valgrind has a non fatal memory leak.
Valgrind's output says:
==2097== Conditional jump or move depends on uninitialised value(s)
==2097== at 0x4481D5: MO_defstring (in /user/ingres/scripts_3.1/demo/API/test_api)
==2097== by 0x446937: MOattach (in /user/ingres/scripts_3.1/demo/API/test_api)
==2097== by 0x41CB01: IIapi_createConnHndl (in /user/ingres/scripts_3.1/demo/API/test_api)
==2097== by 0x4303BD: IIapi_setConnectParam (in /user/ingres/scripts_3.1/demo/API/test_api)
==2097== by 0x4177BF: setConnEnvAPI (ingresAPI.c:5083)
==2097== by 0x405256: connection_environment (test_api.c:636)
==2097== by 0x4047C6: main (test_api.c:296)
==2097== Uninitialised value was created by a stack allocation
==2097== at 0x41C8B4: IIapi_createConnHndl (in /user/ingres/scripts_3.1/demo/API/test_api)
==2097==
In the code snippet below the offending line is simply setting the qp_closure to NULL before the call to IIapi_setConnectParam()...which is what I thought you were supposed to do.
Is this a bug in my code or in API?
Martin Bowes
Code snippet is:
IIAPI_STATUS
setConnEnvAPI(
II_PTR *connHandle,
II_LONG param,
II_PTR value
)
{
II_CHAR Function[] = "setConnEnvAPI()";
IIAPI_SETCONPRMPARM setConnParm;
IIAPI_MODCONNPARM modConnParm;
IIAPI_WAITPARM waitParm = {IIAPI_WAIT_FOREVER};
#ifdef xDEBUG
printf("%s: Called with connHandle = '%0X'\n", Function, *connHandle);
#endif
_init_errorAPI(&gINIT_C);
setConnParm.sc_genParm.gp_callback = NULL;
setConnParm.sc_genParm.gp_closure = NULL; /* This is the line valgrind objects to! */
setConnParm.sc_connHandle = *connHandle;
setConnParm.sc_paramID = param;
setConnParm.sc_paramValue = value;
IIapi_setConnectParam( &setConnParm );
while( setConnParm.sc_genParm.gp_completed == FALSE )
IIapi_wait( &waitParm );
if (setConnParm.sc_genParm.gp_status != IIAPI_ST_SUCCESS)
{
sprintf(gINIT_C.errorAPI.appError, "%s: Failed in call to IIapi_setConnectParam()\n", Function);
_set_errorAPI(&gINIT_C, Function,
setConnParm.sc_genParm.gp_status,
setConnParm.sc_genParm.gp_errorHandle
);
return (IIAPI_ERROR);
};
*connHandle = setConnParm.sc_connHandle;
#ifdef xDEBUG
printf("%s: Completed with connHandle = '%0X'!\n", Function, setConnParm.sc_connHandle);
#endif
return (IIAPI_OK);
}; /* setConnEnvAPI() */
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.planetingres.org/pipermail/info-ingres/attachments/20180425/4035c18f/attachment.html>
More information about the Info-ingres
mailing list