Skip to content

Commit

Permalink
use SimbaEngineSDK version for sf_getenv
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jz authored and Harry Xi committed Oct 26, 2023
1 parent bc93887 commit aba703b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ int STDCALL sf_setenv(const char *name, const char *value) {

char * STDCALL sf_getenv(const char *name) {
#ifdef _WIN32
static char buf[BUFSIZ];
size_t len = 0; // We don't use it, but Windows version doesn't like to pass NULL as lenght pointer. It crashes.
return getenv_s(&len, buf, sizeof(buf) - 1, name) ? NULL : buf;
#else
return getenv(name);
#endif
char* result = NULL;
return _dupenv_s(&result, NULL, name) ? NULL : result;
# else
char* result = getenv(name);
return result ? strdup(result) : NULL;
# endif
}

int STDCALL sf_unsetenv(const char *name) {
Expand Down

0 comments on commit aba703b

Please sign in to comment.