mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-03-25 20:32:14 +00:00
Provide a write callback to cURL.
If we're passing file handles to libcurl to write the data into, the game may crash under Windows due to incompatible C runtimes between cURL and quake2. This is even mentioned in the official cURL doku.
This commit is contained in:
parent
2199b67a39
commit
ec6e0ee392
1 changed files with 8 additions and 2 deletions
|
@ -94,6 +94,12 @@ static size_t CL_HTTP_Recv(void *ptr, size_t size, size_t nmemb, void *stream)
|
|||
return bytes;
|
||||
}
|
||||
|
||||
static size_t CL_HTTP_CurlWriteCB(char* data, size_t size, size_t nmemb, void* userdata)
|
||||
{
|
||||
dlhandle_t *dl = (dlhandle_t *)userdata;
|
||||
return fwrite(data, size, nmemb, dl->file);
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
// Helper functions
|
||||
|
@ -234,8 +240,8 @@ static void CL_StartHTTPDownload (dlqueue_t *entry, dlhandle_t *dl)
|
|||
|
||||
if (dl->file)
|
||||
{
|
||||
qcurl_easy_setopt(dl->curl, CURLOPT_WRITEDATA, dl->file);
|
||||
qcurl_easy_setopt(dl->curl, CURLOPT_WRITEFUNCTION, NULL);
|
||||
qcurl_easy_setopt(dl->curl, CURLOPT_WRITEDATA, dl);
|
||||
qcurl_easy_setopt(dl->curl, CURLOPT_WRITEFUNCTION, CL_HTTP_CurlWriteCB);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue