From a46e600619929beaf8dc27655b743eeb32683149 Mon Sep 17 00:00:00 2001 From: pl Date: Sat, 20 Oct 2001 11:16:47 +0000 Subject: returns a malloc()'ed string instead of an auto char[] git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2304 b3059339-0415-0410-9bf9-f77b7e298cf2 --- cpudetect.c | 17 +++++++++++++---- cpudetect.h | 2 ++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cpudetect.c b/cpudetect.c index ab16cc225b..b7916b18b7 100644 --- a/cpudetect.c +++ b/cpudetect.c @@ -93,9 +93,13 @@ void GetCpuCaps( CpuCaps *caps) printf("CPU vendor name: %.4s%.4s%.4s max cpuid level: %d\n",®s[1],®s[3],®s[2],regs[0]); if (regs[0]>=0x00000001) { + char *tmpstr; + do_cpuid(0x00000001, regs2); - printf("CPU: %s\n",GetCpuFriendlyName(regs, regs2)); + tmpstr=GetCpuFriendlyName(regs, regs2); + printf("CPU: %s\n",tmpstr); + free(tmpstr); caps->cpuType=(regs2[0] >> 8)&0xf; if(caps->cpuType==0xf){ @@ -153,17 +157,22 @@ void GetCpuCaps( CpuCaps *caps) char *GetCpuFriendlyName(unsigned int regs[], unsigned int regs2[]){ #include "cputable.h" /* get cpuname and cpuvendors */ char vendor[17]; - char retname[255]; + char *retname; int i; + if (NULL==(retname=malloc(256))) { + printf("Error: GetCpuFriendlyName() not enough memory\n"); + exit(1); + } + sprintf(vendor,"%.4s%.4s%.4s",®s[1],®s[3],®s[2]); for(i=0; i