Problem with GList
- From: "Michel \\'ZioBudda\\' Morelli" <michel michel enter it>
- To: gtk-list redhat com
- Subject: Problem with GList
- Date: Sat, 25 Jul 1998 20:22:38 +0200 (CEST)
Hi,
I have make this little function that make a GList from a string.
But I have a problem with GList. I can not to make a correct GList.
In one way (this) the "data" of 2nd item is NULL, 3th is ok.
In an another way that i have try the data of 1st item is null.
Why this? And who is the coordinator of glib library? I must to give some
new function. (Or Where is the GTK CVS?. FTP/CVS is ok too).
AH: all the variables that are not defined are defined in my global.h file
(this code is compiled with gcc/RH5.0)
/*This function take 2 argoment:
char *data -- the string
char *delim -- il delimitatore
and return a GList * create from the division of data via delim
*/
GList *
g_string_split(char *delim, char *data)
{ int i,k;
GString *tmps2;
g_list_free(LMail);
LMail = g_list_alloc();
tmps2 = g_string_new(data);
bzero(tmpchar,1024);
g_string_free(ts,TRUE);
for (tmpint = 0; tmpint < (strlen(tmps2->str)); tmpint++)
{ if (!g_strncmp(&tmps2->str[tmpint], delim, strlen(delim)))
{ bzero(tmpchar,1024);
g_string_free(ts,TRUE);
strncpy (tmpchar, tmps2->str, tmpint);
if (LMail->next == NULL && LMail->prev == NULL)
LMail = g_list_insert(LMail, tmpchar,0);
else LMail = g_list_append(LMail, tmpchar);
ts = g_string_new(&tmps2->str[tmpint+1]);
g_string_free(tmps2,TRUE);
tmps2 = g_string_new(ts->str);
tmpint = 0;
}
}
if (tmpint > 1)
{
bzero(tmpchar,1024);
strncpy (tmpchar, tmps2->str, tmpint);
LMail = g_list_insert(LMail, tmpchar,0);
}
//LMail = g_list_insert(LMail, tmps2->str,0);
return LMail;
}
ciaoz
--
Morelli 'ZioBudda' Davide Michel - Member of Pluto Linux User Group
ziobudda@chiara.dei.unipd.it - http://www.dau.ing.univaq.it/~ziobudda/
Linux Problem? Ask to linux@media.dsi.unimi.it
"/dev/ziobudda: access to /var/tmp/beer denied, use /var/adm/pineapple"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]