Memory leak
- From: Rajesh Padalia <rpadalia qatar net qa>
- To: gtk-app-devel-list <gtk-app-devel-list gnome org>
- Subject: Memory leak
- Date: Fri, 29 Nov 2002 21:40:39 +0300
I have follwoing callback function which eats up memory. Can somebody
give me an idea what is wrong with this callback. As I run it several
times it consumes all free memory.
Thanks in advance...
Rajesh
==============
void
on_Get_Config_clicked (GtkButton *button,
gpointer user_data)
{
GtkWidget * gwGet_Config_clist;
GtkWidget * gwGet_Config_Block_Count_entry;
GtkWidget * gwGet_Config_Parameter_entry;
GtkWidget * gwParameter_combo =
lookup_widget(GTK_WIDGET(button),"Get_Config_combo_entry");
GtkWidget * gwSearch_clist =
lookup_widget(GTK_WIDGET(button),"Search_clist");
gpointer memoryblock1;
gpointer memoryblock2;
gpointer memoryblock3;
gchar * Parameter = gtk_entry_get_text(GTK_ENTRY(gwParameter_combo));
gchar ** Search_clist_col;
gchar ** Parameter_Value;
gchar ** Config_Results;
FILE *fconfig;
gchar Config[60];
gboolean CompdFound = FALSE;
gint Search_clist_no_of_rows = 0;
gint Search_clist_row_count = 0;
memoryblock1 = g_malloc(512);
memoryblock2 = g_malloc(512);
memoryblock3 = g_malloc(512);
Parameter_Value = (gchar **) memoryblock1;
Search_clist_col = (gchar **) memoryblock2;
Config_Results = (gchar **) memoryblock3;
Search_clist_col = g_strsplit(" = = = ", "=", 3);
Config_Results = g_strsplit(" = = = = ", "=", 4);
Get_Config_Window = create_Get_Config_Info();
gwGet_Config_clist =
lookup_widget(GTK_WIDGET(Get_Config_Window),"Get_Config_clist");
gwGet_Config_Block_Count_entry =
lookup_widget(GTK_WIDGET(Get_Config_Window),"Get_Config_Block_Count_entry");
gwGet_Config_Parameter_entry =
lookup_widget(GTK_WIDGET(Get_Config_Window),"Get_Config_Parameter_entry");
gtk_clist_clear(GTK_CLIST(gwGet_Config_clist));
Search_clist_no_of_rows = GTK_CLIST(gwSearch_clist)->rows;
gtk_entry_set_text(GTK_ENTRY(gwGet_Config_Block_Count_entry),
g_strdup_printf("%d", Search_clist_no_of_rows));
gtk_entry_set_text(GTK_ENTRY(gwGet_Config_Parameter_entry),
Parameter);
if (Search_clist_no_of_rows > 0) {
do {
gtk_clist_get_text(GTK_CLIST(gwSearch_clist),
Search_clist_row_count, 0, &Search_clist_col[0]);
gtk_clist_get_text(GTK_CLIST(gwSearch_clist),
Search_clist_row_count, 1, &Search_clist_col[1]);
gtk_clist_get_text(GTK_CLIST(gwSearch_clist),
Search_clist_row_count, 2, &Search_clist_col[2]);
gtk_clist_get_text(GTK_CLIST(gwSearch_clist),
Search_clist_row_count, 3, &Search_clist_col[3]);
Parameter_Value = g_strsplit("X=Not Available", "=", 1);
fconfig = fopen(g_strjoin(NULL, CPNameDir, Search_clist_col[0],
NULL), "r");
while (!feof(fconfig)) {
fgets(Config, 60, fconfig);
if (!feof(fconfig)) {
if (g_strcasecmp(Search_clist_col[3], "COMPND") != 0) {
if (g_strcasecmp(Config, g_strdup_printf("NAME = %s:%s\n",
Search_clist_col[1], Search_clist_col[2]))
== 0) {
CompdFound = TRUE;
}
}
else {
if (g_strcasecmp(Config, g_strdup_printf("NAME = %s\n",
Search_clist_col[1])) == 0) {
CompdFound = TRUE;
Search_clist_col[2] = g_strdup(" ");
}
}
if ((strstr(Config, g_strdup_printf(" %-7s= ",
Parameter)))&&(CompdFound == TRUE)) {
Parameter_Value = g_strsplit(Config, "=", 1);
g_strstrip(Parameter_Value[1]);
CompdFound = FALSE;
break;
}
if ((g_strcasecmp(Config, "END\n") == 0)&&(CompdFound == TRUE))
{
Parameter_Value = g_strsplit("X=Not Available", "=", 1);
CompdFound = FALSE;
break;
}
}
}
fclose(fconfig);
Config_Results[0] = g_strdup(Search_clist_col[0]);
Config_Results[1] = g_strdup(Search_clist_col[1]);
Config_Results[2] = g_strdup(Search_clist_col[2]);
Config_Results[3] = g_strdup(Search_clist_col[3]);
Config_Results[4] = g_strdup(Parameter_Value[1]);
gtk_clist_append(GTK_CLIST(gwGet_Config_clist), Config_Results);
Search_clist_row_count++;
g_free(memoryblock1);
g_free(memoryblock2);
g_free(memoryblock3);
} while (Search_clist_row_count < Search_clist_no_of_rows);
gtk_widget_show(Get_Config_Window);
}
else {
Show_Error_Dialog("No Tags in Search List. Use Tag Search to have
minimum one entry in the list");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]