diff options
| author | Michael Vetter <[email protected]> | 2018-11-10 08:29:53 +0100 |
|---|---|---|
| committer | Michael Vetter <[email protected]> | 2018-11-10 08:29:53 +0100 |
| commit | 4c83cee8108e5d56d142117512d1e4bc017b7180 (patch) | |
| tree | 26b1fa91257e35321f8ca11b3bc1a2f1bfe54d20 /src | |
| parent | 5167f78d5f64dfe2a4110102a0a7c1ca197d7c75 (diff) | |
| download | raylib-4c83cee8108e5d56d142117512d1e4bc017b7180.tar.gz raylib-4c83cee8108e5d56d142117512d1e4bc017b7180.zip | |
core: Use dynamic string in OpenURL()
OpenURL() is a function that most games probably will never need.
Wasting 512 bytes to store of a static char to store an the URL is not
wise.
I propose to have it dynamic building the string on the fly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 9 |
1 files changed, 2 insertions, 7 deletions
@@ -1822,10 +1822,7 @@ int StorageLoadValue(int position) // Open URL with default system browser (if available) void OpenURL(const char *url) { - // Max length is "explorer ".length + url.maxlength (which is 2083), - // but we are not wasting that much memory here... let's set it up to 512 - static char cmd[512] = { 0 }; - + char *cmd = calloc(10 + strlen(url), sizeof(char)); #if defined(_WIN32) strcpy(cmd, "explorer "); #elif defined(__linux__) @@ -1833,11 +1830,9 @@ void OpenURL(const char *url) #elif defined(__APPLE__) strcpy(cmd, "open "); #endif - strcat(cmd, url); system(cmd); - - memset(cmd, 0, 512); + free(cmd); } //---------------------------------------------------------------------------------- |
