File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 44
55#include " GameAnalytics/GameAnalytics.h"
66#include " GAUtilities.h"
7+ #include < cstring>
8+ #include < cstdlib>
79
810gameanalytics::StringVector makeStringVector (const char ** arr, int size)
911{
@@ -29,9 +31,26 @@ GA_API void gameAnalytics_freeString(const char* ptr)
2931 std::free ((void *)ptr);
3032}
3133
34+ // Cross-platform string duplication function
35+ static char * ga_strndup (const char * s, size_t n)
36+ {
37+ if (!s) return nullptr ;
38+
39+ size_t len = std::strlen (s);
40+ if (len > n) len = n;
41+
42+ char * result = (char *)std::malloc (len + 1 );
43+ if (result)
44+ {
45+ std::memcpy (result, s, len);
46+ result[len] = ' \0 ' ;
47+ }
48+ return result;
49+ }
50+
3251const char * gameAnalytics_allocString (std::string const & s)
3352{
34- return strndup (s.c_str (), s.size ());
53+ return ga_strndup (s.c_str (), s.size ());
3554}
3655
3756static inline const char * safeString (const char * str)
You can’t perform that action at this time.
0 commit comments