Project

General

Profile

Feature #625 ยป 0080-section_file.-ch-Replace-NULLs-with-nullptrs.patch

Marko Lindqvist, 05/16/2024 03:26 AM

View differences:

utility/registry.h
bool allow_duplicates);
void secfile_allow_digital_boolean(struct section_file *secfile,
bool allow_digital_boolean);
bool allow_digital_boolean)
fc__attribute((nonnull (1)));
const char *secfile_error(void);
const char *section_name(const struct section *psection);
utility/section_file.c
#define DEBUG_ENTRIES(...) /* log_debug(__VA_ARGS__); */
/**********************************************************************//**
Returns the last error which occurred in a string. It never returns NULL.
Returns the last error which occurred in a string.
It never returns nullptr.
**************************************************************************/
const char *secfile_error(void)
{
......
fc_snprintf(error_buffer, sizeof(error_buffer),
"In %s() [%s:%d]: secfile '%s' in section '%s': %s",
function, file, line, secfile_name(secfile),
psection != NULL ? section_name(psection) : "NULL", message);
psection != nullptr ? section_name(psection)
: "nullptr", message);
}
/**********************************************************************//**
......
**************************************************************************/
const char *section_name(const struct section *psection)
{
return (NULL != psection ? psection->name : NULL);
return (psection != nullptr ? psection->name : nullptr);
}
/**********************************************************************//**
......
{
struct section_file *secfile = fc_malloc(sizeof(struct section_file));
secfile->name = NULL;
secfile->name = nullptr;
secfile->num_entries = 0;
secfile->num_includes = 0;
secfile->num_long_comments = 0;
......
secfile->hash.sections = section_hash_new();
/* Maybe allocated later. */
secfile->hash.entries = NULL;
secfile->hash.entries = nullptr;
return secfile;
}
......
**************************************************************************/
void secfile_destroy(struct section_file *secfile)
{
SECFILE_RETURN_IF_FAIL(secfile, NULL, secfile != NULL);
SECFILE_RETURN_IF_FAIL(secfile, nullptr, secfile != nullptr);
section_hash_destroy(secfile->hash.sections);
/* Mark it NULL to be sure to don't try to make operations when
/* Mark it nullptr to be sure to don't try to make operations when
* deleting the entries. */
secfile->hash.sections = NULL;
if (NULL != secfile->hash.entries) {
secfile->hash.sections = nullptr;
if (secfile->hash.entries != nullptr) {
entry_hash_destroy(secfile->hash.entries);
/* Mark it NULL to be sure to don't try to make operations when
/* Mark it nullptr to be sure to don't try to make operations when
* deleting the entries. */
secfile->hash.entries = NULL;
secfile->hash.entries = nullptr;
}
section_list_destroy(secfile->sections);
if (NULL != secfile->name) {
if (secfile->name != nullptr) {
free(secfile->name);
}
......
void secfile_allow_digital_boolean(struct section_file *secfile,
bool allow_digital_boolean)
{
fc_assert_ret(NULL != secfile);
secfile->allow_digital_boolean = allow_digital_boolean;
}
utility/section_file.h
/* The section file struct itself. */
struct section_file {
char *name; /* Can be NULL. */
char *name; /* Can be nullptr. */
size_t num_entries;
/* num_includes should be size_t, but as there's no truly portable
* printf format for size_t and we need to construct string containing
......
}
#endif /* __cplusplus */
#endif /* FC__SECTION_FILE_H */
#endif /* FC__SECTION_FILE_H */
    (1-1/1)