Re: Memory leak



**********************from glib API
g_strdup_printf ()

gchar*      g_strdup_printf                 (const gchar *format,
                                            ...);

Similar to the standard C sprintf() function but safer, since it calculates the maximum space required and allocates memory to hold the result. The returned string should be freed when no longer needed.
************************************************

Hi Rajesh,

you can 'g_strdup_printf' to a local variable and compre it with 'Config' and freee that variable after use.

hope this helps
bijoy.



   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;
       }






________________________________________________________________________
Missed your favourite TV serial last night? Try the new, Yahoo! TV.
      visit http://in.tv.yahoo.com



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