Re: appending a clist row
- From: Clemens Kirchgatterer <clemens linux-austria com>
- To: GTK Application Development List <gtk-app-devel-list gnome org>
- Subject: Re: appending a clist row
- Date: Fri, 05 Jan 2001 10:18:59 +0100
learfox furry ao net wrote:
[..]
One thing you can do is creating a blank array:
gint i, clist_columns = 4;
gchar **text;
/* Allocate a blank array of strings. */
text = (char **)malloc(clist_columns * sizeof(char *));
if(text != NULL)
{
/* Set each pointer to point to an allocated empty string. */
for(i = 0; i < clist_columns; i++)
text[i] = strdup("");
}
just for my curiosity: why do you use strdup() instead of passing the
const char * "" ?
/* Add the item into the clist. */
gtk_clist_append(clist, text);
/* Now deallocate text. */
if(text != NULL)
{
for(i = 0; i < clist_columns; i++)
free(text[i]);
}
free(text);
text = NULL;
clist_columns = 0;
this would not be necerssery, if you wouldn't have used strdup().
regards ...
clemens
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]