g_strstrip question.




  Folks,

  g_strstrip(char*) returns a pointer to the string without the leading and
trailing spaces,

  so here is my string:

   bbbbbbSTRINGbbbbbZ, where this string was allocated with g_strdup,and b=
blank char and Z = NULL.

   When running g_strstrip, I would get:
   bbbbbbSTRINGZbbbbbZ
         ^     |
         |     +--- end of the string is now here.
         |
         +- Pointer returned is now here.

 
 When I do a g_free, would I have a bit of memory leak ? (Since it would free
only the bytes STRING ?

  If so, how do I free the whole string so that I do not get memory leaks ?

  Doing :

      ptr1 = g_strdup("bbbbbbSTRINGbbbbbZ");
      ptr2 = g_strstrip(ptr1);
       ....
      g_free(ptr1);
      g_free(ptr2);
 ???

   Thanks in advance.

   Perhaps I am not understanding well how the memory is being marked to be
freed by the glibc/OS ?

Harring

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



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