removed invalid nullptr checks.
New allocation doesn't gurantee that returns nullptr when it's failed.
It's useless on the modern compliers and our policy respects it.
GlShape* sdata = static_cast<GlShape*>(data);
if (!sdata) {
sdata = new GlShape;
- if (!sdata) return nullptr;
sdata->shape = &shape;
}
SwMpool* mpoolInit(unsigned threads)
{
- auto mpool = new SwMpool;
- if (!mpool) return nullptr;
-
if (threads == 0) threads = 1;
+ auto mpool = new SwMpool;
mpool->outline = static_cast<SwOutline*>(calloc(1, sizeof(SwOutline) * threads));
if (!mpool->outline) goto err;
{
if (!buffer || stride == 0 || w == 0 || h == 0 || w > stride) return false;
- if (!surface) {
- surface = new SwSurface;
- if (!surface) return false;
- }
+ if (!surface) surface = new SwSurface;
surface->buffer = buffer;
surface->stride = stride;
Result Fill::transform(const Matrix& m) noexcept
{
if (!pImpl->transform) pImpl->transform = new Matrix();
- if (!pImpl->transform) return Result::FailedAllocation;
*pImpl->transform = m;
return Result::Success;
}
memcpy(ret->pImpl->colorStops, colorStops, sizeof(ColorStop) * cnt);
if (transform) {
ret->pImpl->transform = new Matrix;
- if (ret->pImpl->transform) *ret->pImpl->transform = *transform;
+ *ret->pImpl->transform = *transform;
}
return ret;
}
{
//function is dedicated for raw images only
auto loader = new RawLoader;
- if (loader) {
- if (loader->open(data, w, h, copy)) return shared_ptr<LoadModule>(loader);
- else delete(loader);
- }
+ if (loader->open(data, w, h, copy)) return shared_ptr<LoadModule>(loader);
+ else delete(loader);
+
return nullptr;
}
//duplicate Transform
if (rTransform) {
ret->pImpl->rTransform = new RenderTransform();
- if (ret->pImpl->rTransform) {
- *ret->pImpl->rTransform = *rTransform;
- ret->pImpl->flag |= RenderUpdateFlag::Transform;
- }
+ *ret->pImpl->rTransform = *rTransform;
+ ret->pImpl->flag |= RenderUpdateFlag::Transform;
}
ret->pImpl->opacity = opacity;
} else {
if (fabsf(degree) <= FLT_EPSILON) return true;
rTransform = new RenderTransform();
- if (!rTransform) return false;
}
rTransform->degree = degree;
if (!rTransform->overriding) flag |= RenderUpdateFlag::Transform;
} else {
if (fabsf(factor) <= FLT_EPSILON) return true;
rTransform = new RenderTransform();
- if (!rTransform) return false;
}
rTransform->scale = factor;
if (!rTransform->overriding) flag |= RenderUpdateFlag::Transform;
} else {
if (fabsf(x) <= FLT_EPSILON && fabsf(y) <= FLT_EPSILON) return true;
rTransform = new RenderTransform();
- if (!rTransform) return false;
}
rTransform->x = x;
rTransform->y = y;
//TODO: Size Exception?
if (!stroke) stroke = new ShapeStroke();
- if (!stroke) return false;
-
stroke->width = width;
flag |= RenderUpdateFlag::Stroke;
bool strokeCap(StrokeCap cap)
{
if (!stroke) stroke = new ShapeStroke();
- if (!stroke) return false;
-
stroke->cap = cap;
flag |= RenderUpdateFlag::Stroke;
bool strokeJoin(StrokeJoin join)
{
if (!stroke) stroke = new ShapeStroke();
- if (!stroke) return false;
-
stroke->join = join;
flag |= RenderUpdateFlag::Stroke;
bool strokeColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
{
if (!stroke) stroke = new ShapeStroke();
- if (!stroke) return false;
-
if (stroke->fill) {
delete(stroke->fill);
stroke->fill = nullptr;
if (!p) return Result::MemoryCorruption;
if (!stroke) stroke = new ShapeStroke();
- if (!stroke) return Result::FailedAllocation;
-
if (stroke->fill && stroke->fill != p) delete(stroke->fill);
stroke->fill = p;
stroke->dashPattern = nullptr;
} else {
if (!stroke) stroke = new ShapeStroke();
- if (!stroke) return false;
-
if (stroke->dashCnt != cnt) {
free(stroke->dashPattern);
stroke->dashPattern = nullptr;
if (!from) return nullptr;
auto grad = new SvgStyleGradient;
- if (!grad) return nullptr;
-
grad->type = from->type;
grad->id = from->id ? _copyId(from->id->c_str()) : nullptr;
grad->ref = from->ref ? _copyId(from->ref->c_str()) : nullptr;
static SvgStyleGradient* _createRadialGradient(SvgLoaderData* loader, const char* buf, unsigned bufLength)
{
auto grad = new SvgStyleGradient;
- if (!grad) return nullptr;
-
loader->svgParse->styleGrad = grad;
grad->type = SvgGradientType::Radial;
static SvgStyleGradient* _createLinearGradient(SvgLoaderData* loader, const char* buf, unsigned bufLength)
{
auto grad = new SvgStyleGradient;
- if (!grad) return nullptr;
-
loader->svgParse->styleGrad = grad;
grad->type = SvgGradientType::Linear;