Re: GTK Progress bar: assistance pls.



On Mon, 7 Jan 2008 14:51:11 +0530 (IST)
vijayasarathy setsindia net wrote:

IN REPLY TO DANS COMMENTS:

1. I am using the g++ compiler and g++ doesnt let a gpointer[return
type of g_malloc0()] or a void pointer point a gchar or a
ProgressData pointer. That is why the typecast.

Ah, so you're using it in C++ mode. Yes, C++ requires the cast, C doesn't.


2. I need more explanation here:

 txt_start_count = (gchar
*)gtk_entry_get_text(GTK_ENTRY(wdgt_start_count));


Useless (possibly dangerous) cast, and you're leaking the memory
g_malloced() above.


Why do you think memory is leaked ?

Because this is, briefly, what you do in your code:

foo = malloc(some_size)
foo = something_else

This leaks some_size bytes of memory. The question is: What is the purpose of g_malloc() in the first place?

I have already done a
lookup_widget on wdgt_start_count. gtk_entry_get_text() returns a
const gchar * value while mine is a gchar *, and that is why the
typecast.

Well then declare txt_start_count as a const char as well.

The typecast is both unneccessary and dangerous in the (unlikely) event that some new version of GTK+, 
gtk_entry_get_text() returns something other than a gchar *.

You really need to get your C act together before embarking on such a project.

--D.



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