Re: frequently updated pixbuf images disapear after a while
- From: "Peter \"Firefly\" Lund" <firefly diku dk>
- To: rupert <rupertt gmail com>
- Cc: John Coppens <john jcoppens com>, gtk-app-devel-list gnome org
- Subject: Re: frequently updated pixbuf images disapear after a while
- Date: Sun, 27 Aug 2006 11:41:33 +0200 (CEST)
On Sun, 27 Aug 2006, rupert wrote:
i changed it to this
gchar mapper_chk_cmd;
mapper_chk_cmd = g_sprintf(MAPPER_PATH, data);
but now i get a warning about a wrong pointer assignment(translated into
english)
in the fopen call.
You ought to get a warning about the mapper_chk_cmd = g_sprintf(...)
assignment, too.
If you don't, then you should turn on more warnings (you need BOTH -W AND
-Wall because gcc programmers are weird).
The reason is of course that mapper_chk_cmd needs to be a gchar * and not
a gchar.
FILE *fp = fopen(mapper_chk_cmd, "r");
if(fp) {
return TRUE;
} else {
return FALSE;
}
fclose(fp);
file descriptor leak.
?? what do you mean with that, how can i fix that?
Open files have a small cost associated with them. You should free those
resources by closing files, particularly when you can't possibly use them
again.
In this case I can tell for sure that you are not going to need the files
because you open them inside a function and the file pointer value
can't escape (at least as the function currently stands).
return TRUE;
}
gboolean crypto_mount_check(gchar *data)
{
gchar mount_chk_cmd[128];
gchar buf[512];
sprintf(mount_chk_cmd, MOUNT_PATH, data);
mount_chk_cmd = g_sprintf(MOUNT_PATH, data);
same aS above
Ditto ;)
FILE *pp = popen(mount_chk_cmd, "r");
if(pp) {
size_t got = fread(buf, 1, sizeof(buf), pp);
pclose(pp);
if(got != 0) {
check also errno.
return TRUE;
} else {
return FALSE;
}
}
return TRUE;
why TRUE?
without I get a warning that a non-void function flew ends(translated.)
Yeah, but I mean, why do you want it to return TRUE and not FALSE?
-Peter
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]