Project

General

Profile

Feature #275 ยป 0039-netfile.c-Replace-NULLs-with-nullptrs.patch

Marko Lindqvist, 02/24/2024 12:20 PM

View differences:

utility/netfile.c
static char error_buf_curl[CURL_ERROR_SIZE];
/* Consecutive transfers can use same handle for better performance */
static CURL *chandle = NULL;
static CURL *chandle = nullptr;
/*******************************************************************//**
Set handle to usable state.
***********************************************************************/
static CURL *netfile_init_handle(void)
{
if (chandle == NULL) {
if (chandle == nullptr) {
chandle = curl_easy_init();
} else {
curl_easy_reset(chandle);
......
nf_errmsg cb, void *data)
{
CURLcode curlret;
struct curl_slist *headers = NULL;
struct curl_slist *headers = nullptr;
static CURL *handle;
bool ret = TRUE;
......
headers = curl_slist_append(headers, "User-Agent: Freeciv/" VERSION_STRING);
curl_easy_setopt(handle, CURLOPT_URL, URL);
if (mem_data != NULL) {
mem_data->mem = NULL;
if (mem_data != nullptr) {
mem_data->mem = nullptr;
mem_data->size = 0;
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, netfile_memwrite_cb);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, mem_data);
......
curl_slist_free_all(headers);
if (curlret != CURLE_OK) {
if (cb != NULL) {
if (cb != nullptr) {
char buf[2048 + CURL_ERROR_SIZE];
fc_snprintf(buf, sizeof(buf),
......
nf_errmsg cb, void *data)
{
bool success;
struct section_file *out = NULL;
struct section_file *out = nullptr;
struct netfile_write_cb_data mem_data;
fz_FILE *file;
success = netfile_download_file_core(URL, NULL, &mem_data, cb, data);
success = netfile_download_file_core(URL, nullptr, &mem_data, cb, data);
if (success) {
file = fz_from_memory(mem_data.mem, mem_data.size, TRUE);
......
fp = fc_fopen(filename, "w+b");
if (fp == NULL) {
if (cb != NULL) {
if (fp == nullptr) {
if (cb != nullptr) {
char buf[2048];
fc_snprintf(buf, sizeof(buf),
......
return FALSE;
}
success = netfile_download_file_core(URL, fp, NULL, cb, data);
success = netfile_download_file_core(URL, fp, nullptr, cb, data);
fclose(fp);
......
{
CURLcode curlret;
long http_resp;
struct curl_slist *headers = NULL;
struct curl_slist *headers = nullptr;
static CURL *handle;
handle = netfile_init_handle();
......
curl_easy_setopt(handle, CURLOPT_HTTPPOST, post->first);
#endif /* HAVE_CURL_MIME_API */
if (mem_data != NULL) {
mem_data->mem = NULL;
if (mem_data != nullptr) {
mem_data->mem = nullptr;
mem_data->size = 0;
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, netfile_memwrite_cb);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, mem_data);
} else if (reply_fp == NULL) {
} else if (reply_fp == nullptr) {
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write);
} else {
curl_easy_setopt(handle, CURLOPT_WRITEDATA, reply_fp);
}
if (addr != NULL) {
if (addr != nullptr) {
curl_easy_setopt(handle, CURLOPT_INTERFACE, addr);
}
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers);
......
void netfile_free(void)
{
#ifndef __EMSCRIPTEN__
if (chandle != NULL) {
if (chandle != nullptr) {
curl_easy_cleanup(chandle);
chandle = NULL;
chandle = nullptr;
}
#endif /* __EMSCRIPTEN__ */
}
    (1-1/1)