Re: Cast from gchar* to int?



On Tue, 24 Sep 2002 20:49:42 -0400
Brandon McCombs <brandon ovnet com> wrote:

int pick3player[3] = { -1, -1, -1 };
pick3player[i] =
atoi(gtk_editable_get_chars(GTK_EDITABLE(pick3entry[i]), 0, -1));

you introduce a memory leak here, there is memory allocated by
gtk_editable_get_chars() and you never free it.

better way:

gchar *tmp = gtk_editable_get_chars(GTK_EDITABLE(pick3entry[i]), 0, -1)
atoi(tmp);
g_free(tmp);


regards,
        Olivier

Attachment: pgpzeBugE_WD3.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]