[settings] add freerdp_settings_take_string

this function can take an allocated value, set the settings string to it
and free it up once replaced by something else.
This commit is contained in:
akallabeth 2023-09-01 13:51:30 +02:00 committed by akallabeth
parent c6535ae689
commit b4ce44c290
2 changed files with 19 additions and 0 deletions

View File

@ -2051,6 +2051,17 @@ extern "C"
FREERDP_API BOOL freerdp_settings_set_string(rdpSettings* settings, size_t id,
const char* param);
/** \brief Takes a string settings value. The \b param is assumed to be malloced (same runtime
* as freerdp library!).
*
* \param settings A pointer to the settings to query, must not be NULL.
* \param id The key to query
* \param param The value to set. Old values are freed up, the value is set as the new one.
*
* \return \b TRUE for success, \b FALSE for failure
*/
FREERDP_API BOOL freerdp_settings_take_string(rdpSettings* settings, size_t id, char* param);
/** \brief Sets a string settings value. The \b param is converted to UTF-8 and the copy stored.
*
* \param settings A pointer to the settings to query, must not be NULL.

View File

@ -2038,6 +2038,14 @@ const char* freerdp_rdp_version_string(UINT32 version)
}
}
BOOL freerdp_settings_take_string(rdpSettings* settings, size_t id, char* param)
{
size_t len = 0;
if (param)
len = strlen(param);
return freerdp_settings_set_string_(settings, id, param, len);
}
BOOL freerdp_settings_set_string_from_utf16(rdpSettings* settings, size_t id, const WCHAR* param)
{
WINPR_ASSERT(settings);