Feature #412 ยป 0059-string_vector.c-Replace-NULLs-with-nullptrs.patch
| utility/string_vector.c | ||
|---|---|---|
|
if (string) {
|
||
|
return fc_strdup(string);
|
||
|
}
|
||
|
return NULL;
|
||
|
return nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| ... | ... | |
|
{
|
||
|
struct strvec *psv = fc_malloc(sizeof(struct strvec));
|
||
|
psv->vec = NULL;
|
||
|
psv->vec = nullptr;
|
||
|
psv->size = 0;
|
||
|
return psv;
|
||
| ... | ... | |
|
/**********************************************************************//**
|
||
|
Stores the string vector from a normal vector. If size == -1, it will
|
||
|
assume it is a NULL terminated vector.
|
||
|
assume it is a nullptr terminated vector.
|
||
|
**************************************************************************/
|
||
|
void strvec_store(struct strvec *psv, const char *const *vec, size_t size)
|
||
|
{
|
||
| ... | ... | |
|
string_free(*p);
|
||
|
}
|
||
|
free(psv->vec);
|
||
|
psv->vec = NULL;
|
||
|
psv->vec = nullptr;
|
||
|
psv->size = 0;
|
||
|
}
|
||
| ... | ... | |
|
string_free(psv->vec[svindex]);
|
||
|
memmove(psv->vec + svindex, psv->vec + svindex + 1,
|
||
|
(psv->size - svindex - 1) * sizeof(char *));
|
||
|
psv->vec[psv->size - 1] = NULL; /* Do not attempt to free this data. */
|
||
|
psv->vec[psv->size - 1] = nullptr; /* Do not attempt to free this data. */
|
||
|
strvec_reserve(psv, psv->size - 1);
|
||
|
return TRUE;
|
||
| ... | ... | |
|
**************************************************************************/
|
||
|
const char *strvec_get(const struct strvec *psv, size_t svindex)
|
||
|
{
|
||
|
return strvec_index_valid(psv, svindex) ? psv->vec[svindex] : NULL;
|
||
|
return strvec_index_valid(psv, svindex) ? psv->vec[svindex] : nullptr;
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| ... | ... | |
|
const char *strvec_to_or_list(const struct strvec *psv,
|
||
|
struct astring *astr)
|
||
|
{
|
||
|
fc_assert_ret_val(NULL != psv, NULL);
|
||
|
fc_assert_ret_val(psv != nullptr, nullptr);
|
||
|
return astr_build_or_list(astr, (const char **) psv->vec, psv->size);
|
||
|
}
|
||
| ... | ... | |
|
const char *strvec_to_and_list(const struct strvec *psv,
|
||
|
struct astring *astr)
|
||
|
{
|
||
|
fc_assert_ret_val(NULL != psv, NULL);
|
||
|
fc_assert_ret_val(psv != nullptr, nullptr);
|
||
|
return astr_build_and_list(astr, (const char **) psv->vec, psv->size);
|
||
|
}
|
||