소스 검색

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.
pull/685/head
Michael Vetter 7 년 전
부모
커밋
4c83cee810
1개의 변경된 파일2개의 추가작업 그리고 7개의 파일을 삭제
  1. +2
    -7
      src/core.c

+ 2
- 7
src/core.c 파일 보기

@ -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);
}
//----------------------------------------------------------------------------------

불러오는 중...
취소
저장