strsplit question (glib)



newbie here...

i'm reading the glib docs, and don't understand strsplit.

suppose i'm writing a shell.  i want to use $PATH to get a list of paths
that my shell will search for executables.

	char *env_path;
	char **search_path;

	env_path = g_getenv("PATH");
	search_path = g_strsplit(env_path, ':', 99);

	...

	g_strfreev(search_path);

ok, so now search_path points to an array of strings.  the docs don't
say a "NULL terminated array of strings".  just an array of strings.

how do i know how many strings are being pointed to?  in other words,
how do i use this array when i have no idea how many elements are in
this array?

another question -- glib provides a GString.  perhaps the most useful
thing in glib.  why in the world would g_strsplit work with arrays of
char *'s instead of g_arrays of GStrings?

pete



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