g_strsplit() return



I have this code:


---SNIP---
GString *my_gstring;
gchar **strings_vector;
gchar **single_string_vector;

my_gstring = g_string_sized_new(1024);
g_string_assign(my_gstring, "AB\tCD\tEF\n12\t34\t56");

strings_vector = g_strsplit(string_vector[i], "\n", -1);
// now string_vector has two elements:
// [0] is AB\tCD\tEF
// [1] is 12\t34\t56


for(i=0;i<2;i++)
{
 single_string_vector = g_strsplit(strings_vector[i], "\t", -1);
 some_other_code();

 g_strfreev(single_string_vector, TRUE); // do I need this here?
}

g_strfreev(strings_vector, TRUE);
---PINS---


The g_strsplit() documentation says it returns a newly-allocated NULL-terminated array of strings.

The "newly-allocated" means that I have to call g_strfreev(single_string_vector, TRUE) in the for loop or can I just do it once outside the cycle?
TIA
--
Regards,
Manuel Ferrero
R&D department

Reer SpA	
Tel.  +39 011 2482215
Fax. +39 011 859867

L'utilizzo non autorizzato del presente messaggio e' vietato e potrebbe costituire reato.
Se il presente messaggio non e' a Lei indirizzato, il suo contenuto non deve essere considerato
come trasmesso o autorizzato dalla Reer SpA; in tale caso Le saremmo grati se, via e-mail,
ce ne comunicasse l'errata ricezione.

The unauthorized use of this e-mail is prohibited and could constitute an offence.
If you are not the intended recipient of this message its contents shall be understood as neither
given nor endorsed by Reer SpA. Please notify Reer SpA by e-mail immediately in that case.



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