Re: Memory leak



Thanks for the reply. I have changed my code as per various responses I
got from this mailing list and is working fine.
Thanks once again.
Rajesh

Clemens Kirchgatterer wrote:

Rajesh Padalia <rpadalia qatar net qa> wrote:

[..]

  gpointer memoryblock1;
  gpointer memoryblock2;
...

[..]

  gchar * Get_Config_Tmp1;
  gchar * Get_Config_Tmp2;
  gchar * Get_Config_Tmp3;
  gchar * Get_Config_Tmp4;

[..]

  memoryblock1 = g_malloc(512);
  memoryblock2 = g_malloc(512);
...

  Get_Config_Tmp1 = (gchar *) memoryblock1;
  Get_Config_Tmp2 = (gchar *) memoryblock2;
  Get_Config_Tmp3 = (gchar *) memoryblock3;
  Get_Config_Tmp4 = (gchar *) memoryblock4;

[..]

  Get_Config_Tmp1 = g_strdup_printf("%d", Search_clist_no_of_rows);
  Get_Config_Tmp4 = g_strdup_printf("  %-7s= ", Parameter);
    ^^^^^^^^^^^^^^^
       gets never freed!
[..]

    Get_Config_Tmp2 = g_strdup_printf("NAME   = %s:%s\n",
Search_clist_col[1], Search_clist_col[2]);
    Get_Config_Tmp3 = g_strdup_printf("NAME   = %s\n",
      ^^^^^^^^^^^^^^^
         the same here

    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]);
      ^^^^^^^^^^^^^^^^
       and here again!

  g_free(memoryblock1);
  g_free(memoryblock2);
  g_free(memoryblock3);
  g_free(memoryblock4);
  g_free(memoryblock5);
  g_free(memoryblock6);
  g_free(memoryblock7);

as i can see you never ever used the memoryblocks. you copied the
pointers to mamoryblocks to your local vars just to overite them right
afterwards. i think you really miss something important about pointers
dynamic memory allocation and the g_strdup_*() functions.

rethink your code.

hope this helps ...
clemens
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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