Re: GList and Combo



Heitham Omar wrote:

Hi,
I've written a function that splits text by spaces and adds them to a
GList:

Some potential problems I see with this code are:

* sizeof(s) might just return the size of a char pointer, on 32 bit machines this will
  be most likely 4. You should use strlen(s) in that case.

* AFAIK a GList just manages the pointers which are passed to it. You should not pass
  a malloc'ed char pointer and free it afterwards. Suggestion: Take a look at g_strdup
  or g_strndup, I found these simple functions to be immensely useful.

* Consider to use strtok to split the strings. This is what it is meant to be for.

WL




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