initialize children size to 0 on childless components

This commit is contained in:
jacekpoz 2024-08-13 01:16:38 +02:00
parent 70ef0e030f
commit 425e6709b4
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -144,6 +144,7 @@ PtkHandle ptk_box(size_t child_count, PtkHandle *children) {
PtkHandle ptk_triangle(PtkPos vertices[3], PtkColor color) {
PtkTriangle *ret = malloc(sizeof(PtkTriangle));
ret->type = PTK_COMPONENT_TYPE_TRIANGLE;
ret->children.size = 0;
memcpy(ret->vertices, vertices, sizeof(PtkPos) * 3);
ret->color = color;
@ -153,6 +154,7 @@ PtkHandle ptk_triangle(PtkPos vertices[3], PtkColor color) {
PtkHandle ptk_rect(PtkPos top_left, PtkSize size, PtkColor color) {
PtkRect *ret = malloc(sizeof(PtkRect));
ret->type = PTK_COMPONENT_TYPE_RECT;
ret->children.size = 0;
ret->top_left = top_left;
ret->size = size;
ret->color = color;
@ -167,6 +169,7 @@ PtkHandle ptk_square(PtkPos top_left, float size, PtkColor color) {
PtkHandle ptk_ellipse(PtkPos center, PtkSize radii, PtkColor color) {
PtkEllipse *ret = malloc(sizeof(PtkEllipse));
ret->type = PTK_COMPONENT_TYPE_ELLIPSE;
ret->children.size = 0;
ret->center = center;
ret->radii = radii;
ret->color = color;
@ -181,6 +184,7 @@ PtkHandle ptk_circle(PtkPos center, float radius, PtkColor color) {
PtkHandle ptk_clickable(PtkHandle hitbox, MouseButtonCallback on_press) {
PtkClickable *ret = malloc(sizeof(PtkClickable));
ret->type = PTK_COMPONENT_TYPE_CLICKABLE;
ret->children.size = 0;
ret->hitbox = hitbox;
ret->on_press = on_press;