char *score_cache_filename;
};
+static void *CreateThreadData_ApiGetScore(int nr)
+{
+ struct ApiGetScoreThreadData *data =
+ checked_malloc(sizeof(struct ApiGetScoreThreadData));
+ char *score_cache_filename = getScoreCacheFilename(nr);
+
+ data->level_nr = nr;
+ data->score_cache_filename = getStringCopy(score_cache_filename);
+
+ return data;
+}
+
+static void FreeThreadData_ApiGetScore(void *data_raw)
+{
+ struct ApiGetScoreThreadData *data = data_raw;
+
+ checked_free(data->score_cache_filename);
+ checked_free(data);
+}
+
static void ApiGetScoreExt(struct HttpRequest *request,
struct HttpResponse *response,
int level_nr,
ApiGetScore(data->level_nr,
data->score_cache_filename);
- checked_free(data->score_cache_filename);
- checked_free(data);
+ FreeThreadData_ApiGetScore(data_raw);
return 0;
}
static void ApiGetScoreAsThread(int nr)
{
- struct ApiGetScoreThreadData *data =
- checked_malloc(sizeof(struct ApiGetScoreThreadData));
- char *score_cache_filename = getScoreCacheFilename(nr);
-
- data->level_nr = nr;
- data->score_cache_filename = getStringCopy(score_cache_filename);
+ struct ApiGetScoreThreadData *data = CreateThreadData_ApiGetScore(nr);
ExecuteAsThread(ApiGetScoreThread,
"ApiGetScore", data,
struct ScoreEntry score_entry;
};
+static void *CreateThreadData_ApiAddScore(int nr, char *score_tape_filename)
+{
+ struct ApiAddScoreThreadData *data =
+ checked_malloc(sizeof(struct ApiAddScoreThreadData));
+ struct ScoreEntry *score_entry = &scores.entry[scores.last_added];
+
+ if (score_tape_filename == NULL)
+ score_tape_filename = getScoreTapeFilename(score_entry->tape_basename, nr);
+
+ data->level_nr = nr;
+ data->score_entry = *score_entry;
+ data->score_tape_filename = getStringCopy(score_tape_filename);
+
+ return data;
+}
+
+static void FreeThreadData_ApiAddScore(void *data_raw)
+{
+ struct ApiAddScoreThreadData *data = data_raw;
+
+ checked_free(data->score_tape_filename);
+ checked_free(data);
+}
+
static void ApiAddScoreExt(struct HttpRequest *request,
struct HttpResponse *response,
int level_nr,
data->score_tape_filename,
&data->score_entry);
- checked_free(data->score_tape_filename);
- checked_free(data);
+ FreeThreadData_ApiAddScore(data_raw);
return 0;
}
static void ApiAddScoreAsThread(int nr, char *score_tape_filename)
{
struct ApiAddScoreThreadData *data =
- checked_malloc(sizeof(struct ApiAddScoreThreadData));
- struct ScoreEntry *score_entry = &scores.entry[scores.last_added];
-
- if (score_tape_filename == NULL)
- score_tape_filename = getScoreTapeFilename(score_entry->tape_basename, nr);
-
- data->level_nr = nr;
- data->score_entry = *score_entry;
- data->score_tape_filename = getStringCopy(score_tape_filename);
+ CreateThreadData_ApiAddScore(nr, score_tape_filename);
ExecuteAsThread(ApiAddScoreThread,
"ApiAddScore", data,
char *player_uuid;
};
+static void *CreateThreadData_ApiRenamePlayer(void)
+{
+ struct ApiRenamePlayerThreadData *data =
+ checked_malloc(sizeof(struct ApiRenamePlayerThreadData));
+
+ data->player_name = getStringCopy(setup.player_name);
+ data->player_uuid = getStringCopy(setup.player_uuid);
+
+ return data;
+}
+
+static void FreeThreadData_ApiRenamePlayer(void *data_raw)
+{
+ struct ApiRenamePlayerThreadData *data = data_raw;
+
+ checked_free(data->player_name);
+ checked_free(data->player_uuid);
+ checked_free(data);
+}
+
static void ApiRenamePlayerExt(struct HttpRequest *request,
struct HttpResponse *response,
char *player_name_raw,
ApiRenamePlayer(data->player_name, data->player_uuid);
- checked_free(data->player_name);
- checked_free(data->player_uuid);
- checked_free(data);
+ FreeThreadData_ApiRenamePlayer(data_raw);
return 0;
}
static void ApiRenamePlayerAsThread(void)
{
struct ApiRenamePlayerThreadData *data =
- checked_malloc(sizeof(struct ApiRenamePlayerThreadData));
-
- data->player_name = getStringCopy(setup.player_name);
- data->player_uuid = getStringCopy(setup.player_uuid);
+ CreateThreadData_ApiRenamePlayer();
ExecuteAsThread(ApiRenamePlayerThread,
"ApiRenamePlayer", data,