aboutsummaryrefslogtreecommitdiff
path: root/src/saffron_widget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/saffron_widget.c')
-rw-r--r--src/saffron_widget.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/saffron_widget.c b/src/saffron_widget.c
index 932b7a5..850d1b8 100644
--- a/src/saffron_widget.c
+++ b/src/saffron_widget.c
@@ -3,10 +3,7 @@
#include <stdlib.h>
#include <saffron.h>
-SaffronWidget* saffron_widget_new(void) {
- /* This function is a generic primitive for creating widgets. You wouldn't want to do this manually unless you're a lunatic. It is meant to be wrapped around by other functions that change the default parameters, for example, what sane person makes a widget 0x0x0x0? you LUNATIC! */
- SaffronWidget* widget = malloc(sizeof(SaffronWidget));
-
+void saffron_widget_init(SaffronWidget* widget) {
widget->x = 0;
widget->y = 0;
widget->w = 0;
@@ -18,6 +15,14 @@ SaffronWidget* saffron_widget_new(void) {
widget->parent = NULL;
widget->children = NULL;
widget->child_count = 0;
+}
+
+SaffronWidget* saffron_widget_new(void) {
+ /* This function is a generic primitive for creating widgets. You wouldn't want to do this manually unless you're a lunatic. It is meant to be wrapped around by other functions that change the default parameters, for example, what sane person makes a widget 0x0x0x0? you LUNATIC! */
+ SaffronWidget* widget = malloc(sizeof(SaffronWidget));
+ if (widget) {
+ saffron_widget_init(widget);
+ }
return widget;
}