Skip to content

Commit a108303

Browse files
committed
return string to avoid dangling ptrs
1 parent 490b7e2 commit a108303

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

source/gameanalytics/Platform/GADeviceOSX.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
#define _GADEVICEOSX_H
33

44
#include "GACommon.h"
5+
#include <string>
56

67
#if IS_MAC
78

8-
const char* getOSXVersion();
9-
const char* getConnectionType();
9+
std::string getOSXVersion();
10+
std::string getConnectionType();
1011
int getNumCpuCores();
1112
int64_t getTotalDeviceMemory();
12-
const char* getGPUName();
13+
std::string getGPUName();
1314

1415
#endif
1516

source/gameanalytics/Platform/GADeviceOSX.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
NSInteger patchVersion;
2727
} MyOperatingSystemVersion;
2828

29-
const char* getOSXVersion()
29+
std::string getOSXVersion()
3030
{
3131
if (floor(kCFCoreFoundationVersionNumber) > kCFCoreFoundationVersionNumber10_9)
3232
{
@@ -64,7 +64,7 @@ SCNetworkReachabilityRef createReachabilityRef()
6464
return reachabilityRef;
6565
}
6666

67-
const char* getConnectionType()
67+
std::string getConnectionType()
6868
{
6969
// todo: keep this in a class
7070
static SCNetworkReachabilityRef reachabilityRef = createReachabilityRef();
@@ -107,7 +107,7 @@ int64_t getTotalDeviceMemory()
107107
return (uint64_t)info.physicalMemory;
108108
}
109109

110-
const char* getGPUName()
110+
std::string getGPUName()
111111
{
112112
NSArray* devices = MTLCopyAllDevices();
113113
if(devices && [devices count])

source/gameanalytics/Platform/GAMacOS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static struct sigaction prevSigAction;
1717

1818
std::string gameanalytics::GAPlatformMacOS::getOSVersion()
1919
{
20-
const char* osxVersion = getOSXVersion();
20+
std::string osxVersion = getOSXVersion();
2121
return getBuildPlatform() + " " + osxVersion;
2222
}
2323

0 commit comments

Comments
 (0)