Re: Memory question
- From: David Rosal <david rosal upf edu>
- To: Allin Cottrell <cottrell wfu edu>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Memory question
- Date: Wed, 28 Sep 2005 10:42:55 +0200
Allin Cottrell wrote:
gchar *text = g_strdup_printf("banana %d", i);
gtk_entry_set_text(GTK_ENTRY(entry), text);
g_free(text);
Is the above code really safe?
You're passing the address of "text" to the function
gtk_entry_set_text(). Next you g_free() that address, so AFAIK the
memory manager marks it as free.
Isn't it dangerous? I mean, after g_free() any call that requests for
memory (g_strdup, g_malloc, ...) can overwrite that memory chunk,
changing the text in the GtkEntry. Am I right?
Cheers,
~david
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]