memory leak fixed in day_item_s2apoint_s()

This commit is contained in:
Frederic Culot 2007-08-04 15:11:47 +00:00
parent ff60394c8e
commit 7903609259
2 changed files with 9 additions and 14 deletions

View File

@ -3,6 +3,7 @@
aerror() and ierror() created to improve error handling while in ncurses aerror() and ierror() created to improve error handling while in ncurses
mode mode
exit_calcurse() updated to take exit code as argument exit_calcurse() updated to take exit code as argument
memory leak fixed in day_item_s2apoint_s()
29 Jul 2007: 29 Jul 2007:
compiler warnings fixed compiler warnings fixed

View File

@ -1,4 +1,4 @@
/* $calcurse: day.c,v 1.27 2007/08/04 14:34:03 culot Exp $ */ /* $calcurse: day.c,v 1.28 2007/08/04 15:11:47 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -292,18 +292,13 @@ day_process_storage(date_t *slctd_date, bool day_changed, day_items_nb_t *inday)
* Returns a structure of type apoint_llist_node_t given a structure of type * Returns a structure of type apoint_llist_node_t given a structure of type
* day_item_s * day_item_s
*/ */
static apoint_llist_node_t * static void
day_item_s2apoint_s(struct day_item_s *p) day_item_s2apoint_s(apoint_llist_node_t *a, struct day_item_s *p)
{ {
apoint_llist_node_t *a;
a = (apoint_llist_node_t *) malloc(sizeof(apoint_llist_node_t));
a->mesg = (char *) malloc(strlen(p->mesg) + 1);
a->state = p->state; a->state = p->state;
a->start = p->start; a->start = p->start;
a->dur = p->appt_dur; a->dur = p->appt_dur;
a->mesg = p->mesg; a->mesg = p->mesg;
return a;
} }
/* /*
@ -317,6 +312,7 @@ void
day_write_pad(long date, int width, int length, int incolor) day_write_pad(long date, int width, int length, int incolor)
{ {
struct day_item_s *p; struct day_item_s *p;
apoint_llist_node_t a;
int line, item_number, max_pos, recur; int line, item_number, max_pos, recur;
const int x_pos = 0; const int x_pos = 0;
bool draw_line = false; bool draw_line = false;
@ -357,17 +353,15 @@ day_write_pad(long date, int width, int length, int incolor)
/* Last print the appointments for current day. */ /* Last print the appointments for current day. */
item_number++; item_number++;
day_item_s2apoint_s(&a, p);
if (item_number - incolor == 0) { if (item_number - incolor == 0) {
day_saved_item->type = p->type; day_saved_item->type = p->type;
day_saved_item->mesg = p->mesg; day_saved_item->mesg = p->mesg;
apoint_sec2str(day_item_s2apoint_s(p), apoint_sec2str(&a, p->type, date,
p->type, date, day_saved_item->start, day_saved_item->end);
day_saved_item->start,
day_saved_item->end);
} }
display_item_date(apad->ptrwin, item_number - incolor, display_item_date(apad->ptrwin, item_number - incolor,
day_item_s2apoint_s(p), p->type, date, &a, p->type, date, line + 1, x_pos);
line + 1, x_pos);
display_item(apad->ptrwin, item_number - incolor, p->mesg, display_item(apad->ptrwin, item_number - incolor, p->mesg,
0, width - 7, line + 2, x_pos + 2); 0, width - 7, line + 2, x_pos + 2);
line = line + 3; line = line + 3;