#define ms2sec(ms) (long long int)(ms / 1000.0)
#define sec2ms(s) (s * 1000.0)
-#define lli2p(x) ((gpointer)((time_t)x))
/* input order
* UCAL_MONTH + UCAL_DAY_OF_MONTH
}
}
-static int __get_exdate_list(UCalendar *ucal, cal_event_s *event, GList **l, int *count)
+static int __get_exdate_list(UCalendar *ucal, cal_event_s *event, GList **list)
{
RETV_IF(NULL == ucal, CALENDAR_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == event, CALENDAR_ERROR_INVALID_PARAMETER);
break;
}
DBG("%lld", lli);
- *l = g_list_append(*l, lli2p(lli));
+
+ long long int *lli_p = calloc(1, sizeof(long long int));
+ if (NULL == lli_p) {
+ break;
+ }
+ *lli_p = lli;
+
+ *list = g_list_append(*list, lli_p);
}
- if (count) *count = len;
- DBG("exdate len(%d)", len);
g_strfreev(t);
return CALENDAR_ERROR_NONE;
return false;
}
-static bool __check_exdate_to_skip(long long int get_lli, int exdate_len, GList **l)
+static bool __check_exdate_to_skip(long long int get_lli, GList **list)
{
int i = 0;
- for (i = 0; i < exdate_len; i++) {
- long long int exdate_lli = (long long int)g_list_nth_data(*l, i);
- if (exdate_lli == get_lli) {
+
+ GList *cursor = *list;
+ while (cursor) {
+ long long int *lli_p = (long long int *)cursor->data;
+ if (NULL == lli_p) {
+ cursor = g_list_next(cursor);
+ continue;
+ }
+ long long int lli = *lli_p;
+ if (lli == get_lli) {
DBG("found exdate(%lld)", get_lli);
- *l = g_list_remove(*l, lli2p(get_lli));
+ free(lli_p);
+ *list = g_list_delete_link(*list, cursor);
return true;
}
+ cursor = g_list_next(cursor);
}
return false;
}
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos len(%d)", bysetpos_len);
- GList *l = NULL;
- int exdate_len = 0;
- __get_exdate_list(ucal, event, &l, &exdate_len);
+ GList *list = NULL;
+ __get_exdate_list(ucal, event, &list);
int loop = 0;
int count = 0;
if (true == __check_before_dtstart(current_utime, dtstart_utime))
continue;
- if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (true == __check_exdate_to_skip(current_utime, &list)) {
count++;
continue;
}
is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
loop++;
}
- if (l) g_list_free(l);
+ if (list)
+ g_list_free_full(list, free);
return CALENDAR_ERROR_NONE;
}
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos len(%d)", bysetpos_len);
- GList *l = NULL;
- int exdate_len = 0;
- __get_exdate_list(ucal, event, &l, &exdate_len);
+ GList *list = NULL;
+ __get_exdate_list(ucal, event, &list);
int loop = 0;
int count = 0;
if (true == __check_before_dtstart(current_utime, dtstart_utime))
continue;
- if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (true == __check_exdate_to_skip(current_utime, &list)) {
count++;
continue;
}
is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
loop++;
}
- if (l) g_list_free(l);
+ if (list)
+ g_list_free_full(list, free);
return CALENDAR_ERROR_NONE;
}
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos len(%d)", bysetpos_len);
- GList *l = NULL;
- int exdate_len = 0;
- __get_exdate_list(ucal, event, &l, &exdate_len);
- DBG("exdate_len(%d)", exdate_len);
+ GList *list = NULL;
+ __get_exdate_list(ucal, event, &list);
int loop = 0;
int count = 0;
if (true == __check_before_dtstart(current_utime, dtstart_utime))
continue;
- if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (true == __check_exdate_to_skip(current_utime, &list)) {
count++;
continue;
}
if (true == __check_before_dtstart(current_utime, dtstart_utime))
continue;
- if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (true == __check_exdate_to_skip(current_utime, &list)) {
count++;
continue;
}
if (true == __check_before_dtstart(current_utime, dtstart_utime))
continue;
- if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (true == __check_exdate_to_skip(current_utime, &list)) {
count++;
continue;
}
loop++;
}
g_strfreev(t);
- if (l) g_list_free(l);
+ if (list)
+ g_list_free_full(list, free);
return CALENDAR_ERROR_NONE;
}
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos len(%d)", bysetpos_len);
- GList *l = NULL;
- int exdate_len = 0;
- __get_exdate_list(ucal, event, &l, &exdate_len);
+ GList *list = NULL;
+ __get_exdate_list(ucal, event, &list);
int loop = 0;
int count = 0;
if (true == __check_before_dtstart(current_utime, dtstart_utime))
continue;
- if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (true == __check_exdate_to_skip(current_utime, &list)) {
count++;
continue;
}
is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
loop++;
}
- if (l) g_list_free(l);
+ if (list)
+ g_list_free_full(list, free);
return CALENDAR_ERROR_NONE;
}
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos len(%d)", bysetpos_len);
- GList *l = NULL;
- int exdate_len = 0;
- __get_exdate_list(ucal, event, &l, &exdate_len);
- DBG("exdate_len(%d)", exdate_len);
+ GList *list = NULL;
+ __get_exdate_list(ucal, event, &list);
int loop = 0;
int count = 0;
if (true == __check_before_dtstart(current_utime, dtstart_utime))
continue;
- if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (true == __check_exdate_to_skip(current_utime, &list)) {
count++;
continue;
}
if (true == __check_before_dtstart(current_utime, dtstart_utime))
continue;
- if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (true == __check_exdate_to_skip(current_utime, &list)) {
count++;
continue;
}
if (true == __check_before_dtstart(current_utime, dtstart_utime))
continue;
- if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (true == __check_exdate_to_skip(current_utime, &list)) {
count++;
continue;
}
loop++;
}
g_strfreev(t);
- if (l) g_list_free(l);
+ if (list)
+ g_list_free_full(list, free);
return CALENDAR_ERROR_NONE;
}
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos_len(%d)", bysetpos_len);
- GList *l = NULL;
- int exdate_len = 0;
- __get_exdate_list(ucal, event, &l, &exdate_len);
- DBG("exdate_len(%d)", bysetpos_len);
+ GList *list = NULL;
+ __get_exdate_list(ucal, event, &list);
int loop = 0;
int count = 0;
if (true == __check_before_dtstart(current_utime, dtstart_utime))
continue;
- if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (true == __check_exdate_to_skip(current_utime, &list)) {
count++;
continue;
}
is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
loop++;
}
- if (l) g_list_free(l);
+ if (list)
+ g_list_free_full(list, free);
return CALENDAR_ERROR_NONE;
}
_cal_db_instance_parse_byint(event->bysetpos, bysetpos, &bysetpos_len);
DBG("bysetpos len(%d)", bysetpos_len);
- GList *l = NULL;
- int exdate_len = 0;
- __get_exdate_list(ucal, event, &l, &exdate_len);
+ GList *list = NULL;
+ __get_exdate_list(ucal, event, &list);
int byday_start = ucal_getAttribute(ucal, UCAL_FIRST_DAY_OF_WEEK);
DBG("get first day of week(%d)", byday_start);
if (true == __check_before_dtstart(current_utime, dtstart_utime))
continue;
- if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (true == __check_exdate_to_skip(current_utime, &list)) {
count++;
continue;
}
is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
loop++;
}
- if (l) g_list_free(l);
+ if (list)
+ g_list_free_full(list, free);
return CALENDAR_ERROR_NONE;
}
int bymonth_len = 0;
_cal_db_instance_parse_byint(event->bymonth, bymonth, &bymonth_len);
- GList *l = NULL;
- int exdate_len = 0;
- __get_exdate_list(ucal, event, &l, &exdate_len);
+ GList *list = NULL;
+ __get_exdate_list(ucal, event, &list);
calendar_time_s *st = &event->start;
__set_time_to_ucal(event->system_type, ucal, st);
if (0 == loop) loop = 1;
continue;
}
- if (true == __check_exdate_to_skip(current_utime, exdate_len, &l)) {
+ if (true == __check_exdate_to_skip(current_utime, &list)) {
if (0 == loop) loop = 1;
count++;
continue;
is_exit = __check_to_stop_loop(current_utime, &last_utime, loop);
loop++;
}
- if (l) g_list_free(l);
+ if (list)
+ g_list_free_full(list, free);
return CALENDAR_ERROR_NONE;
}