[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Problem in one program...
- From: Bryan Wilkinson <nardo pobox com>
- To: gtk-app-devel-list redhat com
- Subject: Re: Problem in one program...
- Date: Mon, 9 Aug 1999 02:52:15 -0400 (EDT)
> I written this program, but not fuction correct! Why? This program read
> entries in /etc/passwd and add in on GList *list.
getpwent() uses a single passwd structure, when you make successive calls
to it, the pointer returned from the previous call points to the newly
updated passwd structure, this is why you are getting multiple copies of
the same structure. you will need to make a function to copy the fields of
the passwd structure.
> user = (gpointer) g_malloc (sizeof(struct passwd));
this memory is leaked since you assign to user in the very next line
> user = getpwent ();
[snip]
> show = (gpointer) g_malloc (sizeof(struct passwd));
this memory is leaked as well
> show = (struct passwd*)listrunner->data;
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]