aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/apoint.c19
-rwxr-xr-xsrc/event.c19
-rwxr-xr-xsrc/io.c34
-rwxr-xr-xsrc/recur.c56
-rwxr-xr-xsrc/todo.c8
5 files changed, 55 insertions, 81 deletions
diff --git a/src/apoint.c b/src/apoint.c
index 4a8d3ef..91c7885 100755
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -1,4 +1,4 @@
-/* $calcurse: apoint.c,v 1.36 2009/07/12 16:21:58 culot Exp $ */
+/* $calcurse: apoint.c,v 1.37 2009/07/19 08:20:00 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -65,16 +65,7 @@ apoint_free_bkp (erase_flag_e flag)
mem_free (bkp_cut_apoint.mesg);
bkp_cut_apoint.mesg = 0;
}
- if (bkp_cut_apoint.note)
- {
- if (flag == ERASE_FORCE)
- erase_note (&bkp_cut_apoint.note, ERASE_FORCE);
- else
- {
- mem_free (bkp_cut_apoint.note);
- bkp_cut_apoint.note = 0;
- }
- }
+ erase_note (&bkp_cut_apoint.note, flag);
}
static void
@@ -114,8 +105,7 @@ apoint_llist_free (void)
o = *i;
*i = o->next;
mem_free (o->mesg);
- if (o->note)
- mem_free (o->note);
+ erase_note (&o->note, ERASE_FORCE_KEEP_NOTE);
mem_free (o);
}
mem_free (alist_p);
@@ -547,8 +537,7 @@ apoint_delete_bynum (long start, unsigned num, erase_flag_e flag)
case ERASE_CUT:
apoint_free_bkp (ERASE_FORCE);
apoint_dup (i, &bkp_cut_apoint);
- if (i->note)
- mem_free (i->note);
+ erase_note (&i->note, ERASE_FORCE_KEEP_NOTE);
/* FALLTHROUGH */
default:
if (notify_bar ())
diff --git a/src/event.c b/src/event.c
index 109313f..9b1cd63 100755
--- a/src/event.c
+++ b/src/event.c
@@ -1,4 +1,4 @@
-/* $calcurse: event.c,v 1.14 2009/07/05 20:33:19 culot Exp $ */
+/* $calcurse: event.c,v 1.15 2009/07/19 08:20:00 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -57,16 +57,7 @@ event_free_bkp (erase_flag_e flag)
mem_free (bkp_cut_event.mesg);
bkp_cut_event.mesg = 0;
}
- if (bkp_cut_event.note)
- {
- if (flag == ERASE_FORCE)
- erase_note (&bkp_cut_event.note, ERASE_FORCE);
- else
- {
- mem_free (bkp_cut_event.note);
- bkp_cut_event.note = 0;
- }
- }
+ erase_note (&bkp_cut_event.note, flag);
}
static void
@@ -92,8 +83,7 @@ event_llist_free (void)
o = *i;
*i = o->next;
mem_free (o->mesg);
- if (o->note)
- mem_free (o->note);
+ erase_note (&o->note, ERASE_FORCE_KEEP_NOTE);
mem_free (o);
}
}
@@ -224,8 +214,7 @@ event_delete_bynum (long start, unsigned num, erase_flag_e flag)
case ERASE_CUT:
event_free_bkp (ERASE_FORCE);
event_dup (i, &bkp_cut_event);
- if (i->note)
- mem_free (i->note);
+ erase_note (&i->note, ERASE_FORCE_KEEP_NOTE);
/* FALLTHROUGH */
default:
*iptr = i->next;
diff --git a/src/io.c b/src/io.c
index 582d91e..8d51e81 100755
--- a/src/io.c
+++ b/src/io.c
@@ -1,4 +1,4 @@
-/* $calcurse: io.c,v 1.69 2009/07/15 18:48:44 culot Exp $ */
+/* $calcurse: io.c,v 1.70 2009/07/19 08:20:00 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -1666,8 +1666,7 @@ ical_store_todo (int priority, char *mesg, char *note)
{
todo_add (mesg, priority, note);
mem_free (mesg);
- if (note)
- mem_free (note);
+ erase_note (&note, ERASE_FORCE_KEEP_NOTE);
}
static void
@@ -1699,7 +1698,7 @@ ical_store_event (char *mesg, char *note, long day, long end, ical_rpt_t *rpt,
event_new (mesg, note, day, EVENTID);
}
mem_free (mesg);
- mem_free (note);
+ erase_note (&note, ERASE_FORCE_KEEP_NOTE);
}
static void
@@ -1710,7 +1709,7 @@ ical_store_apoint (char *mesg, char *note, long start, long dur,
if (has_alarm)
state |= APOINT_NOTIFY;
- if (rpt != NULL)
+ if (rpt)
{
recur_apoint_new (mesg, note, start, dur, state, rpt->type, rpt->freq,
rpt->until, &exc);
@@ -1721,8 +1720,7 @@ ical_store_apoint (char *mesg, char *note, long start, long dur,
apoint_new (mesg, note, start, dur, state);
}
mem_free (mesg);
- if (note)
- mem_free (note);
+ erase_note (&note, ERASE_FORCE_KEEP_NOTE);
}
/*
@@ -2524,11 +2522,15 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints,
"The end of item was not found."));
cleanup:
-
- mem_free (vevent.note);
- mem_free (vevent.mesg);
- mem_free (vevent.rpt);
- mem_free (vevent.exc);
+
+ if (vevent.note)
+ mem_free (vevent.note);
+ if (vevent.mesg)
+ mem_free (vevent.mesg);
+ if (vevent.rpt)
+ mem_free (vevent.rpt);
+ if (vevent.exc)
+ mem_free (vevent.exc);
(*noskipped)++;
}
@@ -2621,9 +2623,11 @@ ical_read_todo (FILE *fdi, FILE *log, unsigned *notodos, unsigned *noskipped,
"The end of item was not found."));
cleanup:
-
- mem_free (vtodo.note);
- mem_free (vtodo.mesg);
+
+ if (vtodo.note)
+ mem_free (vtodo.note);
+ if (vtodo.mesg)
+ mem_free (vtodo.mesg);
(*noskipped)++;
}
diff --git a/src/recur.c b/src/recur.c
index ee35d41..e21bf0c 100755
--- a/src/recur.c
+++ b/src/recur.c
@@ -1,4 +1,4 @@
-/* $calcurse: recur.c,v 1.51 2009/07/05 20:33:23 culot Exp $ */
+/* $calcurse: recur.c,v 1.52 2009/07/19 08:20:01 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -116,16 +116,7 @@ recur_event_free_bkp (erase_flag_e flag)
free_exc (bkp_cut_recur_event.exc);
bkp_cut_recur_event.exc = 0;
}
- if (bkp_cut_recur_event.note)
- {
- if (flag == ERASE_FORCE)
- erase_note (&bkp_cut_recur_event.note, ERASE_FORCE);
- else
- {
- mem_free (bkp_cut_recur_event.note);
- bkp_cut_recur_event.note = 0;
- }
- }
+ erase_note (&bkp_cut_recur_event.note, flag);
}
void
@@ -146,16 +137,7 @@ recur_apoint_free_bkp (erase_flag_e flag)
free_exc (bkp_cut_recur_apoint.exc);
bkp_cut_recur_apoint.exc = 0;
}
- if (bkp_cut_recur_apoint.note)
- {
- if (flag == ERASE_FORCE)
- erase_note (&bkp_cut_recur_apoint.note, ERASE_FORCE);
- else
- {
- mem_free (bkp_cut_recur_apoint.note);
- bkp_cut_recur_apoint.note = 0;
- }
- }
+ erase_note (&bkp_cut_recur_apoint.note, flag);
}
static void
@@ -720,15 +702,21 @@ recur_event_erase (long start, unsigned num, unsigned delete_whole,
case ERASE_CUT:
recur_event_free_bkp (ERASE_FORCE);
recur_event_dup (i, &bkp_cut_recur_event);
- if (i->note)
- mem_free (i->note);
+ erase_note (&i->note, ERASE_FORCE_KEEP_NOTE);
/* FALLTHROUGH */
default:
*iptr = i->next;
mem_free (i->mesg);
- mem_free (i->rpt);
- free_exc (i->exc);
- i->exc = 0;
+ if (i->rpt)
+ {
+ mem_free (i->rpt);
+ i->rpt = 0;
+ }
+ if (i->exc)
+ {
+ free_exc (i->exc);
+ i->exc = 0;
+ }
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
erase_note (&i->note, flag);
mem_free (i);
@@ -783,15 +771,21 @@ recur_apoint_erase (long start, unsigned num, unsigned delete_whole,
case ERASE_CUT:
recur_apoint_free_bkp (ERASE_FORCE);
recur_apoint_dup (i, &bkp_cut_recur_apoint);
- if (i->note)
- mem_free (i->note);
+ erase_note (&i->note, ERASE_FORCE_KEEP_NOTE);
/* FALLTHROUGH */
default:
*iptr = i->next;
mem_free (i->mesg);
- mem_free (i->rpt);
- free_exc (i->exc);
- i->exc = 0;
+ if (i->rpt)
+ {
+ mem_free (i->rpt);
+ i->rpt = 0;
+ }
+ if (i->exc)
+ {
+ free_exc (i->exc);
+ i->exc = 0;
+ }
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
erase_note (&i->note, flag);
mem_free (i);
diff --git a/src/todo.c b/src/todo.c
index b2dbd5e..3d5ff10 100755
--- a/src/todo.c
+++ b/src/todo.c
@@ -1,4 +1,4 @@
-/* $calcurse: todo.c,v 1.34 2009/07/12 16:22:01 culot Exp $ */
+/* $calcurse: todo.c,v 1.35 2009/07/19 08:20:01 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -240,8 +240,7 @@ todo_delete_bynum (unsigned num, erase_flag_e flag)
{
*iptr = i->next;
mem_free (i->mesg);
- if (i->note != NULL)
- erase_note (&i->note, flag);
+ erase_note (&i->note, flag);
mem_free (i);
return;
}
@@ -540,8 +539,7 @@ todo_free_list (void)
o = *i;
*i = o->next;
mem_free (o->mesg);
- if (o->note != 0)
- erase_note (&o->note, ERASE_FORCE_KEEP_NOTE);
+ erase_note (&o->note, ERASE_FORCE_KEEP_NOTE);
mem_free (o);
}
if (todolist)