Feature #1729 ยป 0028-citizens.c-Replace-NULL-with-nullptr.patch
| common/citizens.c | ||
|---|---|---|
|
* slots are allocated as once. Considering a size of citizens (= char)
|
||
|
* this results in an allocation of 2 * 128 * 1 bytes for the citizens
|
||
|
* per nation as well as the timer for a nationality change. */
|
||
|
if (pcity->nationality == NULL) {
|
||
|
if (pcity->nationality == nullptr) {
|
||
|
/* Allocate the memory*/
|
||
|
pcity->nationality = fc_calloc(MAX_NUM_PLAYER_SLOTS,
|
||
|
sizeof(*pcity->nationality));
|
||
| ... | ... | |
|
if (pcity->nationality) {
|
||
|
free(pcity->nationality);
|
||
|
pcity->nationality = NULL;
|
||
|
pcity->nationality = nullptr;
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
return 0;
|
||
|
}
|
||
|
fc_assert_ret_val(pslot != NULL, 0);
|
||
|
fc_assert_ret_val(pcity != NULL, 0);
|
||
|
fc_assert_ret_val(pcity->nationality != NULL, 0);
|
||
|
fc_assert_ret_val(pslot != nullptr, 0);
|
||
|
fc_assert_ret_val(pcity != nullptr, 0);
|
||
|
fc_assert_ret_val(pcity->nationality != nullptr, 0);
|
||
|
return *(pcity->nationality + player_slot_index(pslot));
|
||
|
}
|
||
| ... | ... | |
|
return;
|
||
|
}
|
||
|
fc_assert_ret(pslot != NULL);
|
||
|
fc_assert_ret(pcity != NULL);
|
||
|
fc_assert_ret(pcity->nationality != NULL);
|
||
|
fc_assert_ret(pslot != nullptr);
|
||
|
fc_assert_ret(pcity != nullptr);
|
||
|
fc_assert_ret(pcity->nationality != nullptr);
|
||
|
fc_assert_ret(MAX_CITY_SIZE - nationality >= add);
|
||
|
fc_assert_ret(nationality >= -add);
|
||
| ... | ... | |
|
return;
|
||
|
}
|
||
|
fc_assert_ret(pslot != NULL);
|
||
|
fc_assert_ret(pcity != NULL);
|
||
|
fc_assert_ret(pcity->nationality != NULL);
|
||
|
fc_assert_ret(pslot != nullptr);
|
||
|
fc_assert_ret(pcity != nullptr);
|
||
|
fc_assert_ret(pcity->nationality != nullptr);
|
||
|
*(pcity->nationality + player_slot_index(pslot)) = count;
|
||
|
}
|
||
| ... | ... | |
|
/* If the citizens of a nation is greater than 0 there should be a player
|
||
|
* for this nation. This test should only be done on the server as the
|
||
|
* client does not has the knowledge about all players all the time. */
|
||
|
fc_assert_ret_val(!is_server() || player_slot_get_player(pslot) != NULL,
|
||
|
fc_assert_ret_val(!is_server() || player_slot_get_player(pslot) != nullptr,
|
||
|
city_size_get(pcity));
|
||
|
count += nationality;
|
||
| ... | ... | |
|
fc_assert(FALSE);
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||