apache / uima-uimacpp

C++ support for Apache UIMA
https://uima.apache.org/
Apache License 2.0
15 stars 19 forks source link

Refactor error handling for memory allocation failure #23

Open mac-op opened 4 months ago

mac-op commented 4 months ago

Describe the refactoring action The codebase uses C++'s new but handles allocation failures as if it were C's malloc by checking if the returned pointer is NULL, while new in C++ throws a std::bad_alloc if it fails, unless the call is marked with std::no_throw.

Possible actions

An overview of misuses: Collected by a Python script, may not be complete

./src/jni/jni.cpp:
    [line:356] pInstance
./src/utils/deployCppService.hpp:
    [line:848] singleton_pLogger
./src/utils/runAECpp.cpp:
    [line:382] pBuffer
./src/utils/ActiveMQAnalysisEngineService.cpp:
    [line:620] connection
    [line:638] connection
    [line:1290] newConnection
    [line:1353] newListener
    [line:1378] iv_pgetMetaConnection
    [line:1396] newListener
./src/framework/engine.cpp:
    [line:215] pResult
./src/framework/taespecifierbuilder.cpp:
    [line:186] iv_pXMLErrorHandler
    [line:232] iv_pXMLErrorHandler
    [line:271] iv_pXMLErrorHandler
    [line:313] iv_pXMLErrorHandler
    [line:1898] iv_pXMLErrorHandler
    [line:1980] iv_pXMLErrorHandler
./src/framework/annotator_context.cpp:
    [line:169] iv_pCasPool
./src/framework/internal_primitive_engine.cpp:
    [line:102] iv_pAnnotator
./src/framework/resmgr.cpp:
    [line:581] pDllFile
    [line:670] cv_pclSingletonInstance->iv_fileLogger
./examples/src/ExampleApplication.cpp:
    [line:201] pBuffer
mac-op commented 4 months ago

This can be a good new issue