mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-05 00:46:16 +01:00
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
This commit is contained in:
parent
9352cdb5f4
commit
58abc1fc19
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user