This particular code is really complicated. Look at this mess
typedef struct NSVGattrib {
char id[64];
float xform[6];
gfx::rgba_pixel<32> fillColor;
gfx::rgba_pixel<32> strokeColor;
float opacity;
float fillOpacity;
float strokeOpacity;
char fillGradient[64];
char strokeGradient[64];
float strokeWidth;
float strokeDashOffset;
float strokeDashArray[NSVG_MAX_DASHES];
int strokeDashCount;
svg_line_join strokeLineJoin;
svg_line_cap strokeLineCap;
float miterLimit;
svg_fill_rule fillRule;
float fontSize;
gfx::rgba_pixel<32> stopColor;
float stopOpacity;
float stopOffset;
char hasFill;
char hasStroke;
char visible;
} NSVGattrib;
using reader_t = ml_reader_ex<2048>;
struct svg_css_class {
char selector[512];
char* value;
svg_css_class* next;
};
struct svg_parse_result {
reader_t* reader;
svg_css_class* css_classes;
svg_css_class* css_class_tail;
void* (*allocator)(size_t);
void* (*reallocator)(void*, size_t);
void (*deallocator)(void*);
char lname[32];
char aname[512];
char avalue[512];
char style_val[256];
char class_val[128];
char* d;
size_t d_size;
NSVGattrib attr[NSVG_MAX_ATTR];
int attrHead;
float* pts;
int npts;
int cpts;
svg_path* plist;
size_t image_size;
svg_image_info* image;
NSVGgradientData* gradients;
svg_shape* shapesTail;
float viewMinx, viewMiny, viewWidth, viewHeight;
int alignX, alignY, alignType;
float dpi;
char pathFlag;
char defsFlag;
};
I highlighted the portion of the inner structure I forgot to initialize (the head attribute, as the rest are copied from that)
Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix