/* Construct a string describing the fds and r/w flags in GPOLLFDS,
e.g. " 0(r)" */
- gchar * string = "";
+ gchar * string = NULL;
GSList * scan = gpollfds;
while (scan != NULL)
{
GPollFD * gfd = scan->data;
int mode = (gfd->events) & (~(G_IO_HUP|G_IO_ERR));
- gchar * next = g_strdup_printf ("%s %d(%s)", string, gfd->fd,
- (mode == (G_IO_IN|G_IO_OUT) ? "rw"
- : mode == G_IO_IN ? "r"
- : mode == G_IO_OUT ? "w" : "?"));
- if (string[0] != '\0')
+ gchar * next = g_strdup_printf ("%s %d(%s)",
+ (string == NULL ? "" : string),
+ gfd->fd,
+ (mode == (G_IO_IN|G_IO_OUT) ? "rw"
+ : mode == G_IO_IN ? "r"
+ : mode == G_IO_OUT ? "w" : "?"));
+ if (string != NULL)
g_free (string);
string = next;
scan = scan->next;