Re: g_idle_add source & memory leaks
- From: Olivier Sessink <oliviersessink gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: g_idle_add source & memory leaks
- Date: Wed, 11 May 2011 08:53:45 +0200
On 05/09/2011 01:36 PM, Gabriele Greco wrote:
just a note on your example code: use the GPOINTER_TO_INT and
GINT_TO_POINTER macro's to avoid 64bit portability problems:
gboolean mycbk(gpointer data)
{
gint val = GPOINTER_TO_INT(data);
char buffer[16];
sprintf(buffer, "%09d", val);
gtk_label_set_text(l, buffer);
return FALSE;
}
void threadfunc(void *unused) {
gint msec = 0;
while (1) {
msec++;
g_usleep(1000);
g_idle_add((GSourceFunc)mycbk, GINT_TO_POINTER(msec));
}
}
Olivier
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]