common initializer: correct the result value.

When memory is not allocated successully, it must return the FailedAllocation as the return value.
Previous initializer wrongly returns the value that case, this corrects it.
This commit is contained in:
Hermet Park 2021-06-03 20:48:02 +09:00
parent c2b2aa92c3
commit efa0035fe6
2 changed files with 3 additions and 3 deletions

View file

@ -1272,7 +1272,7 @@ public:
* @param[in] threads The number of additional threads. Zero indicates only the main thread is to be used. * @param[in] threads The number of additional threads. Zero indicates only the main thread is to be used.
* *
* @retval Result::Success When succeed. * @retval Result::Success When succeed.
* @retval Result::InsufficientCondition An internal error possibly with memory allocation. * @retval Result::FailedAllocation An internal error possibly with memory allocation.
* @retval Result::InvalidArguments If unknown engine type chosen. * @retval Result::InvalidArguments If unknown engine type chosen.
* @retval Result::NonSupport In case the engine type is not supported on the system. * @retval Result::NonSupport In case the engine type is not supported on the system.
* @retval Result::Unknown Others. * @retval Result::Unknown Others.

View file

@ -49,12 +49,12 @@ Result Initializer::init(CanvasEngine engine, uint32_t threads) noexcept
if (static_cast<uint32_t>(engine) & static_cast<uint32_t>(CanvasEngine::Sw)) { if (static_cast<uint32_t>(engine) & static_cast<uint32_t>(CanvasEngine::Sw)) {
#ifdef THORVG_SW_RASTER_SUPPORT #ifdef THORVG_SW_RASTER_SUPPORT
if (!SwRenderer::init(threads)) return Result::InsufficientCondition; if (!SwRenderer::init(threads)) return Result::FailedAllocation;
nonSupport = false; nonSupport = false;
#endif #endif
} else if (static_cast<uint32_t>(engine) & static_cast<uint32_t>(CanvasEngine::Gl)) { } else if (static_cast<uint32_t>(engine) & static_cast<uint32_t>(CanvasEngine::Gl)) {
#ifdef THORVG_GL_RASTER_SUPPORT #ifdef THORVG_GL_RASTER_SUPPORT
if (!GlRenderer::init(threads)) return Result::InsufficientCondition; if (!GlRenderer::init(threads)) return Result::FailedAllocation;
nonSupport = false; nonSupport = false;
#endif #endif
} else { } else {