Files
libgtop/sysdeps/common/procargs.c
James Henstridge aa5ac8fc10 remove unused file.
2005-12-12  James Henstridge  <james@jamesh.id.au>

	* doc/auto-macros.texi.in: remove unused file.

	* doc/libgtop2.texi: don't include auto-macros.texi.

	* doc/Makefile.am: don't build auto-macros.texi, since none of its
	macros are used in the documentation any more.

	* include/glibtop/global.h: don't include <config.h> from headers.

	* .../*.c: make sure <config.h> is the first thing included.

	* acinclude.m4: m4_include() libgtop-sysdeps.m4 rather than
	inlining it.

	* acinclude.m4, libgtop-sysdeps.m4: use third argument to
	AC_DEFINE() to set the comment.

	* configure.in: modernise a bit.

	* acconfig.h: remove file, since it is deprecated

	* autogen.sh: require automake 1.9 instead of 1.4.
2005-12-12 09:38:15 +00:00

45 lines
926 B
C

#include <config.h>
#include <glibtop/procargs.h>
#include <glib.h>
#include <string.h>
/*
Splitting args0
* args0 [......0.. ....0.........0]
* Returned value must be free with g_strfreev
* args0 is g_free()d
*/
static char **
split_args0(const char * const args0, size_t size)
{
GPtrArray *argv = g_ptr_array_new();
const char *arg;
/* remember that if there were no args, args0 == NULL and size == 0 */
for (arg = args0; arg < (args0 + size); arg += strlen(arg) + 1) {
g_ptr_array_add(argv, g_strdup(arg));
}
g_ptr_array_add(argv, NULL);
g_free((void* /* remove constness */) args0);
return (char**) g_ptr_array_free(argv, FALSE);
}
/*
* public functions
*/
char **
glibtop_get_proc_argv_l (glibtop *server, glibtop_proc_args *buf,
pid_t pid, unsigned max_len)
{
const char * const args0 = glibtop_get_proc_args_l(server, buf, pid, max_len);
return split_args0(args0, buf->size);
}