{
icalproperty *prop = icalcomponent_get_first_property(inst->comp, ICAL_CATEGORIES_PROPERTY);
- event_t *event = calloc(1, sizeof(event_t));
+ event_t *event = new0(event_t);
event->name = icalcomponent_get_summary(inst->comp);
event->desc = icalcomponent_get_description(inst->comp);
event->loc = icalcomponent_get_location(inst->comp);
icalproperty *cat = icalcomponent_get_first_property(inst->comp, ICAL_CATEGORIES_PROPERTY);
icalproperty *perc = icalcomponent_get_first_property(inst->comp, ICAL_PERCENTCOMPLETE_PROPERTY);
- todo_t *todo = calloc(1, sizeof(todo_t));
+ todo_t *todo = new0(todo_t);
todo->name = icalcomponent_get_summary(inst->comp);
todo->desc = icalcomponent_get_description(inst->comp);
todo->cat = icalproperty_get_value_as_string(cat);
*cur = repl;
}
+/* Memory functions */
+void *alloc0(int size)
+{
+ void *data = calloc(1, size);
+ if (!data)
+ error("memory allocation failed");
+ return data;
+}
+
/* Debugging functions */
void debug(char *fmt, ...)
{
#define ROUND(x) ((int)((x)+0.5))
#define N_ELEMENTS(x) (sizeof(x)/sizeof((x)[0]))
+#define new0(type) alloc0(sizeof(type))
+
/* Debug functions */
void util_init(void);
/* Stirng functions */
void strsub(char *str, char find, char repl);
+/* Memory functions */
+void *alloc0(int size);
+
/* Debug functions */
void debug(char *fmt, ...);
void error(char *fmt, ...);