From 2e128614133d12e5638fb0da9c119c5dbe6bb878 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Sun, 28 Apr 2019 19:51:59 +0100 Subject: [PATCH] Set uname in stack. --- setter/unix.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/setter/unix.c b/setter/unix.c index 6e47bac..0b70033 100644 --- a/setter/unix.c +++ b/setter/unix.c @@ -40,33 +40,22 @@ Copyright (C) 2011-2018 Natalia Portillo void GetOsInfo() { - struct utsname *uname_buf; - int ret; + struct utsname buf; + int ret; - uname_buf = malloc(sizeof(struct utsname)); - - if(!uname_buf) - { - printf("Error %d allocating memory.\n", errno); - return; - } - - ret = uname(uname_buf); + ret = uname(&buf); if(ret) { - free(uname_buf); printf("Error %d retrieving OS information.\n", errno); return; } printf("OS information:\n"); - printf("\tOS name: %s\n", uname_buf->sysname); - printf("\tRelease: %s\n", uname_buf->release); - printf("\tVersion: %s\n", uname_buf->version); - printf("\tMachine: %s\n", uname_buf->machine); - - free(uname_buf); + printf("\tOS name: %s\n", buf.sysname); + printf("\tRelease: %s\n", buf.release); + printf("\tVersion: %s\n", buf.version); + printf("\tMachine: %s\n", buf.machine); } void GetVolumeInfo(const char *path, size_t *clusterSize)