projects
/
rocksndiamonds.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f1aebde
)
changed thread functions to be more generic regarding passed data
author
Holger Schemel
<info@artsoft.org>
Wed, 23 Jun 2021 07:50:45 +0000
(09:50 +0200)
committer
Holger Schemel
<info@artsoft.org>
Wed, 23 Jun 2021 07:50:45 +0000
(09:50 +0200)
src/files.c
patch
|
blob
|
history
diff --git
a/src/files.c
b/src/files.c
index 93d38e7c44e2d238e1cc7bb9b64168c489e30b2b..2daffc83846a1a7c3e3fb7dea3c7eb6ec105bd6b 100644
(file)
--- a/
src/files.c
+++ b/
src/files.c
@@
-9002,14
+9002,10
@@
void SaveScore(int nr)
SaveScoreToFilename(filename);
}
SaveScoreToFilename(filename);
}
-static void ExecuteAsThread(SDL_ThreadFunction function, char *name,
int
data,
+static void ExecuteAsThread(SDL_ThreadFunction function, char *name,
void *
data,
char *error)
{
char *error)
{
- static int data_static;
-
- data_static = data;
-
- SDL_Thread *thread = SDL_CreateThread(function, name, &data_static);
+ SDL_Thread *thread = SDL_CreateThread(function, name, data);
if (thread != NULL)
SDL_DetachThread(thread);
if (thread != NULL)
SDL_DetachThread(thread);
@@
-9098,17
+9094,28
@@
static void DownloadServerScoreToCache(int nr)
checked_free(response);
}
checked_free(response);
}
-st
atic int DownloadServerScoreToCacheThread(void *data)
+st
ruct DownloadServerScoreToCacheThreadData
{
{
- DownloadServerScoreToCache(*(int *)data);
+ int level_nr;
+};
+
+static int DownloadServerScoreToCacheThread(void *data_raw)
+{
+ struct DownloadServerScoreToCacheThreadData *data = data_raw;
+
+ DownloadServerScoreToCache(data->level_nr);
return 0;
}
static void DownloadServerScoreToCacheAsThread(int nr)
{
return 0;
}
static void DownloadServerScoreToCacheAsThread(int nr)
{
+ static struct DownloadServerScoreToCacheThreadData data;
+
+ data.level_nr = nr;
+
ExecuteAsThread(DownloadServerScoreToCacheThread,
ExecuteAsThread(DownloadServerScoreToCacheThread,
- "DownloadServerScoreToCache",
nr
,
+ "DownloadServerScoreToCache",
&data
,
"download scores from server");
}
"download scores from server");
}
@@
-9353,17
+9360,28
@@
static void UploadScoreToServer(int nr)
checked_free(response);
}
checked_free(response);
}
-static int UploadScoreToServerThread(void *data)
+struct UploadScoreToServerThreadData
+{
+ int level_nr;
+};
+
+static int UploadScoreToServerThread(void *data_raw)
{
{
- UploadScoreToServer(*(int *)data);
+ struct UploadScoreToServerThreadData *data = data_raw;
+
+ UploadScoreToServer(data->level_nr);
return 0;
}
static void UploadScoreToServerAsThread(int nr)
{
return 0;
}
static void UploadScoreToServerAsThread(int nr)
{
+ static struct UploadScoreToServerThreadData data;
+
+ data.level_nr = nr;
+
ExecuteAsThread(UploadScoreToServerThread,
ExecuteAsThread(UploadScoreToServerThread,
- "UploadScoreToServer",
nr
,
+ "UploadScoreToServer",
&data
,
"upload score to server");
}
"upload score to server");
}