Commit 58abc1fc authored by Antoine Jacoutot's avatar Antoine Jacoutot

platform_get_argv0: drop unneeded headers for OpenBSD

And properly set the size of len.
There is also no need for realloc(), g_malloc0 will do just fine.

https://bugzilla.gnome.org/show_bug.cgi?id=728280
parent 9352cdb5
......@@ -185,9 +185,7 @@
#include <errno.h>
#if defined __OpenBSD__
#include <sys/types.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#endif
......@@ -1763,13 +1761,16 @@ platform_get_argv0 (void)
g_free (cmdline);
return base_arg0;
#elif defined __OpenBSD__
char **cmdline = NULL;
char **cmdline;
char *base_arg0;
gsize len = PATH_MAX;
gsize len;
int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV };
cmdline = (char **) realloc (cmdline, len);
if (sysctl (mib, G_N_ELEMENTS (mib), NULL, &len, NULL, 0) == -1)
return NULL;
cmdline = g_malloc0 (len);
if (sysctl (mib, G_N_ELEMENTS (mib), cmdline, &len, NULL, 0) == -1)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment