Project

General

Profile

Feature #2410 ยป 0098-update_queue.c-Replace-NULL-with-nullptr.patch

Marko Lindqvist, 10/24/2026 02:29 AM

View differences:

client/update_queue.c
#define SPECHASH_IDATA_FREE waiting_queue_list_destroy
#include "spechash.h"
static struct update_queue_hash *update_queue = NULL;
static struct waiting_queue_hash *processing_started_waiting_queue = NULL;
static struct waiting_queue_hash *processing_finished_waiting_queue = NULL;
static struct update_queue_hash *update_queue = nullptr;
static struct waiting_queue_hash *processing_started_waiting_queue = nullptr;
static struct waiting_queue_hash *processing_finished_waiting_queue = nullptr;
static int update_queue_frozen_level = 0;
static bool update_queue_has_idle_callback = FALSE;
......
****************************************************************************/
static void update_queue_data_destroy(struct update_queue_data *uq_data)
{
fc_assert_ret(NULL != uq_data);
if (NULL != uq_data->free_data_func) {
fc_assert_ret(uq_data != nullptr);
if (uq_data->free_data_func != nullptr) {
uq_data->free_data_func(uq_data->data);
}
free(uq_data);
......
****************************************************************************/
static void waiting_queue_data_destroy(struct waiting_queue_data *wq_data)
{
fc_assert_ret(NULL != wq_data);
if (NULL != wq_data->uq_data) {
/* May be NULL, see waiting_queue_data_extract(). */
fc_assert_ret(wq_data != nullptr);
if (wq_data->uq_data != nullptr) {
/* May be nullptr, see waiting_queue_data_extract(). */
update_queue_data_destroy(wq_data->uq_data);
}
free(wq_data);
......
{
struct update_queue_data *uq_data = wq_data->uq_data;
wq_data->uq_data = NULL;
wq_data->uq_data = nullptr;
return uq_data;
}
/************************************************************************//**
Initialize the update queue.
****************************************************************************/
void update_queue_init(void)
{
if (NULL != update_queue) {
if (update_queue != nullptr) {
/* Already initialized. */
fc_assert(NULL != processing_started_waiting_queue);
fc_assert(NULL != processing_finished_waiting_queue);
fc_assert(processing_started_waiting_queue != nullptr);
fc_assert(processing_finished_waiting_queue != nullptr);
return;
}
fc_assert(NULL == processing_started_waiting_queue);
fc_assert(NULL == processing_finished_waiting_queue);
fc_assert(processing_started_waiting_queue == nullptr);
fc_assert(processing_finished_waiting_queue == nullptr);
update_queue = update_queue_hash_new();
processing_started_waiting_queue = waiting_queue_hash_new();
......
****************************************************************************/
void update_queue_free(void)
{
fc_assert(NULL != update_queue);
fc_assert(NULL != processing_started_waiting_queue);
fc_assert(NULL != processing_finished_waiting_queue);
fc_assert(update_queue != nullptr);
fc_assert(processing_started_waiting_queue != nullptr);
fc_assert(processing_finished_waiting_queue != nullptr);
if (NULL != update_queue) {
if (update_queue != nullptr) {
update_queue_hash_destroy(update_queue);
update_queue = NULL;
update_queue = nullptr;
}
if (NULL != processing_started_waiting_queue) {
if (processing_started_waiting_queue != nullptr) {
waiting_queue_hash_destroy(processing_started_waiting_queue);
processing_started_waiting_queue = NULL;
processing_started_waiting_queue = nullptr;
}
if (NULL != processing_finished_waiting_queue) {
if (processing_finished_waiting_queue != nullptr) {
waiting_queue_hash_destroy(processing_finished_waiting_queue);
processing_finished_waiting_queue = NULL;
processing_finished_waiting_queue = nullptr;
}
update_queue_frozen_level = 0;
......
update_queue_frozen_level--;
if (0 == update_queue_frozen_level
&& !update_queue_has_idle_callback
&& NULL != update_queue
&& update_queue != nullptr
&& 0 < update_queue_hash_size(update_queue)) {
update_queue_has_idle_callback = TRUE;
add_idle_callback(update_unqueue, NULL);
add_idle_callback(update_unqueue, nullptr);
} else if (0 > update_queue_frozen_level) {
log_error("update_queue_frozen_level < 0, repairing...");
update_queue_frozen_level = 0;
......
{
struct waiting_queue_list *list;
if (NULL == hash || !waiting_queue_hash_lookup(hash, request_id, &list)) {
if (hash == nullptr || !waiting_queue_hash_lookup(hash, request_id, &list)) {
return;
}
......
{
struct update_queue_hash *hash;
if (NULL == update_queue) {
if (update_queue == nullptr) {
update_queue_has_idle_callback = FALSE;
return;
}
......
if (!update_queue_has_idle_callback
&& !update_queue_is_frozen()) {
update_queue_has_idle_callback = TRUE;
add_idle_callback(update_unqueue, NULL);
add_idle_callback(update_unqueue, nullptr);
}
}
......
****************************************************************************/
void update_queue_add(uq_callback_t callback, void *data)
{
if (NULL != update_queue) {
update_queue_push(callback, update_queue_data_new(data, NULL));
if (update_queue != nullptr) {
update_queue_push(callback, update_queue_data_new(data, nullptr));
}
}
......
void update_queue_add_full(uq_callback_t callback, void *data,
uq_free_fn_t free_data_func)
{
if (NULL != update_queue) {
if (update_queue != nullptr) {
update_queue_push(callback, update_queue_data_new(data, free_data_func));
}
}
......
****************************************************************************/
bool update_queue_has_callback(uq_callback_t callback)
{
return (NULL != update_queue
&& update_queue_hash_lookup(update_queue, callback, NULL));
return (update_queue != nullptr
&& update_queue_hash_lookup(update_queue, callback, nullptr));
}
/************************************************************************//**
Returns whether this callback is listed in the update queue and
get the its data and free function. 'data' and 'free_data_func' can
be NULL.
be nullptr.
****************************************************************************/
bool update_queue_has_callback_full(uq_callback_t callback,
const void **data,
uq_free_fn_t *free_data_func)
{
if (NULL != update_queue) {
if (update_queue != nullptr) {
struct update_queue_data *uq_data;
if (update_queue_hash_lookup(update_queue, callback, &uq_data)) {
if (NULL != data) {
if (data != nullptr) {
*data = uq_data->data;
}
if (NULL != free_data_func) {
if (free_data_func != nullptr) {
*free_data_func = uq_data->free_data_func;
}
return TRUE;
}
}
return FALSE;
}
......
int request_id, uq_callback_t callback,
void *data, uq_free_fn_t free_data_func)
{
if (NULL != hash) {
if (hash != nullptr) {
struct waiting_queue_list *list;
if (!waiting_queue_hash_lookup(hash, request_id, &list)) {
......
void *data)
{
waiting_queue_add_pending_request(processing_started_waiting_queue,
request_id, callback, data, NULL);
request_id, callback, data, nullptr);
}
/************************************************************************//**
......
void *data)
{
waiting_queue_add_pending_request(processing_finished_waiting_queue,
request_id, callback, data, NULL);
request_id, callback, data, nullptr);
}
/************************************************************************//**
......
const void *data;
if (update_queue_has_callback_full(set_client_page_callback,
&data, NULL)) {
&data, nullptr)) {
return FC_PTR_TO_INT(data);
} else {
return get_current_client_page();
......
****************************************************************************/
void multipliers_dialog_update(void)
{
update_queue_add(real_multipliers_dialog_update, NULL);
update_queue_add(real_multipliers_dialog_update, nullptr);
}
/************************************************************************//**
......
void popup_city_dialog(struct city *pcity)
{
pcity->client.need_updates |= CU_POPUP_DIALOG;
update_queue_add(cities_update_callback, NULL);
update_queue_add(cities_update_callback, nullptr);
}
/************************************************************************//**
......
void refresh_city_dialog(struct city *pcity)
{
pcity->client.need_updates |= CU_UPDATE_DIALOG;
update_queue_add(cities_update_callback, NULL);
update_queue_add(cities_update_callback, nullptr);
}
/************************************************************************//**
......
void city_report_dialog_update_city(struct city *pcity)
{
pcity->client.need_updates |= CU_UPDATE_REPORT;
update_queue_add(cities_update_callback, NULL);
update_queue_add(cities_update_callback, nullptr);
}
/************************************************************************//**
......
****************************************************************************/
void conn_list_dialog_update(void)
{
update_queue_add(real_conn_list_dialog_update, NULL);
update_queue_add(real_conn_list_dialog_update, nullptr);
}
/************************************************************************//**
......
****************************************************************************/
void players_dialog_update(void)
{
update_queue_add(real_players_dialog_update, NULL);
update_queue_add(real_players_dialog_update, nullptr);
}
/************************************************************************//**
......
****************************************************************************/
void city_report_dialog_update(void)
{
update_queue_add(real_city_report_dialog_update, NULL);
update_queue_add(real_city_report_dialog_update, nullptr);
}
/************************************************************************//**
......
****************************************************************************/
void science_report_dialog_update(void)
{
update_queue_add(real_science_report_dialog_update, NULL);
update_queue_add(real_science_report_dialog_update, nullptr);
}
/************************************************************************//**
......
****************************************************************************/
void economy_report_dialog_update(void)
{
update_queue_add(real_economy_report_dialog_update, NULL);
update_queue_add(real_economy_report_dialog_update, nullptr);
}
/************************************************************************//**
......
****************************************************************************/
void units_report_dialog_update(void)
{
update_queue_add(real_units_report_dialog_update, NULL);
update_queue_add(real_units_report_dialog_update, nullptr);
}
/************************************************************************//**
......
****************************************************************************/
void unit_select_dialog_update(void)
{
update_queue_add(unit_select_dialog_update_real, NULL);
update_queue_add(unit_select_dialog_update_real, nullptr);
}
    (1-1/1)