|
@@ -202,26 +202,34 @@ namespace bx
|
|
|
#endif // BX_PLATFORM_
|
|
#endif // BX_PLATFORM_
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void* dlsym(void* _handle, const char* _symbol)
|
|
|
|
|
|
|
+ void* dlsym(void* _handle, const StringView& _symbol)
|
|
|
{
|
|
{
|
|
|
|
|
+ const int32_t symbolMax = _symbol.getLength()+1;
|
|
|
|
|
+ char* symbol = (char*)alloca(symbolMax);
|
|
|
|
|
+ bx::strCopy(symbol, symbolMax, _symbol);
|
|
|
|
|
+
|
|
|
#if BX_PLATFORM_WINDOWS
|
|
#if BX_PLATFORM_WINDOWS
|
|
|
- return (void*)::GetProcAddress( (HMODULE)_handle, _symbol);
|
|
|
|
|
|
|
+ return (void*)::GetProcAddress( (HMODULE)_handle, symbol);
|
|
|
#elif BX_PLATFORM_EMSCRIPTEN \
|
|
#elif BX_PLATFORM_EMSCRIPTEN \
|
|
|
|| BX_PLATFORM_PS4 \
|
|
|| BX_PLATFORM_PS4 \
|
|
|
|| BX_PLATFORM_XBOXONE \
|
|
|| BX_PLATFORM_XBOXONE \
|
|
|
|| BX_PLATFORM_WINRT \
|
|
|| BX_PLATFORM_WINRT \
|
|
|
|| BX_CRT_NONE
|
|
|| BX_CRT_NONE
|
|
|
- BX_UNUSED(_handle, _symbol);
|
|
|
|
|
|
|
+ BX_UNUSED(_handle, symbol);
|
|
|
return NULL;
|
|
return NULL;
|
|
|
#else
|
|
#else
|
|
|
- return ::dlsym(_handle, _symbol);
|
|
|
|
|
|
|
+ return ::dlsym(_handle, symbol);
|
|
|
#endif // BX_PLATFORM_
|
|
#endif // BX_PLATFORM_
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- bool getEnv(const char* _name, char* _out, uint32_t* _inOutSize)
|
|
|
|
|
|
|
+ bool getEnv(char* _out, uint32_t* _inOutSize, const StringView& _name)
|
|
|
{
|
|
{
|
|
|
|
|
+ const int32_t nameMax = _name.getLength()+1;
|
|
|
|
|
+ char* name = (char*)alloca(nameMax);
|
|
|
|
|
+ bx::strCopy(name, nameMax, _name);
|
|
|
|
|
+
|
|
|
#if BX_PLATFORM_WINDOWS
|
|
#if BX_PLATFORM_WINDOWS
|
|
|
- DWORD len = ::GetEnvironmentVariableA(_name, _out, *_inOutSize);
|
|
|
|
|
|
|
+ DWORD len = ::GetEnvironmentVariableA(name, _out, *_inOutSize);
|
|
|
bool result = len != 0 && len < *_inOutSize;
|
|
bool result = len != 0 && len < *_inOutSize;
|
|
|
*_inOutSize = len;
|
|
*_inOutSize = len;
|
|
|
return result;
|
|
return result;
|
|
@@ -229,10 +237,10 @@ namespace bx
|
|
|
|| BX_PLATFORM_XBOXONE \
|
|
|| BX_PLATFORM_XBOXONE \
|
|
|
|| BX_PLATFORM_WINRT \
|
|
|| BX_PLATFORM_WINRT \
|
|
|
|| BX_CRT_NONE
|
|
|| BX_CRT_NONE
|
|
|
- BX_UNUSED(_name, _out, _inOutSize);
|
|
|
|
|
|
|
+ BX_UNUSED(name, _out, _inOutSize);
|
|
|
return false;
|
|
return false;
|
|
|
#else
|
|
#else
|
|
|
- const char* ptr = ::getenv(_name);
|
|
|
|
|
|
|
+ const char* ptr = ::getenv(name);
|
|
|
uint32_t len = 0;
|
|
uint32_t len = 0;
|
|
|
bool result = false;
|
|
bool result = false;
|
|
|
if (NULL != ptr)
|
|
if (NULL != ptr)
|
|
@@ -251,23 +259,35 @@ namespace bx
|
|
|
#endif // BX_PLATFORM_
|
|
#endif // BX_PLATFORM_
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void setEnv(const char* _name, const char* _value)
|
|
|
|
|
|
|
+ void setEnv(const StringView& _name, const StringView& _value)
|
|
|
{
|
|
{
|
|
|
|
|
+ const int32_t nameMax = _name.getLength()+1;
|
|
|
|
|
+ char* name = (char*)alloca(nameMax);
|
|
|
|
|
+ bx::strCopy(name, nameMax, _name);
|
|
|
|
|
+
|
|
|
|
|
+ char* value = NULL;
|
|
|
|
|
+ if (!_value.isEmpty() )
|
|
|
|
|
+ {
|
|
|
|
|
+ int32_t valueMax = _value.getLength()+1;
|
|
|
|
|
+ value = (char*)alloca(valueMax);
|
|
|
|
|
+ bx::strCopy(value, valueMax, _value);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
#if BX_PLATFORM_WINDOWS
|
|
#if BX_PLATFORM_WINDOWS
|
|
|
- ::SetEnvironmentVariableA(_name, _value);
|
|
|
|
|
|
|
+ ::SetEnvironmentVariableA(name, value);
|
|
|
#elif BX_PLATFORM_PS4 \
|
|
#elif BX_PLATFORM_PS4 \
|
|
|
|| BX_PLATFORM_XBOXONE \
|
|
|| BX_PLATFORM_XBOXONE \
|
|
|
|| BX_PLATFORM_WINRT \
|
|
|| BX_PLATFORM_WINRT \
|
|
|
|| BX_CRT_NONE
|
|
|| BX_CRT_NONE
|
|
|
- BX_UNUSED(_name, _value);
|
|
|
|
|
|
|
+ BX_UNUSED(name, value);
|
|
|
#else
|
|
#else
|
|
|
- if (NULL != _value)
|
|
|
|
|
|
|
+ if (NULL != value)
|
|
|
{
|
|
{
|
|
|
- ::setenv(_name, _value, 1);
|
|
|
|
|
|
|
+ ::setenv(name, value, 1);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- ::unsetenv(_name);
|
|
|
|
|
|
|
+ ::unsetenv(name);
|
|
|
}
|
|
}
|
|
|
#endif // BX_PLATFORM_
|
|
#endif // BX_PLATFORM_
|
|
|
}
|
|
}
|