\label{doc_decisions_1_problem_clear_key_string_return_value_md_md_doc_decisions_1_problem_clear_key_string_return_value}%
\Hypertarget{doc_decisions_1_problem_clear_key_string_return_value_md_md_doc_decisions_1_problem_clear_key_string_return_value}%
 \hypertarget{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1950}{}\doxysection{Problem}\label{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1950}
When using \mbox{\hyperlink{group__keyvalue_ga880936f2481d28e6e2acbe7486a21d05}{key\+String()}} on empty / binary values the return values are the literal strings (null) / (binary). This seems very awkward and unintuitive from a user\textquotesingle{}s perspective.\hypertarget{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1951}{}\doxysection{Constraints}\label{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1951}
Because the return value of the function is {\ttfamily const char$\ast$}, there are not so many possibilities for a change to this behavior, as every possible return value -\/ except for a NULL pointer -\/ could just be the value of the string of the Key.\hypertarget{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1952}{}\doxysection{Assumptions}\label{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1952}
On one hand always returning a string allows things like {\ttfamily strlen(key\+String(k)) == 0} to check for an empty string. But at the same time people might expect that {\ttfamily strlen(key\+String(k)) $<$ MAX\+\_\+\+LEN} also works. But this again might silently break code down the line, if {\ttfamily k} is binary and {\ttfamily strlen(\char`\"{}(binary)\char`\"{}) $<$ MAX\+\_\+\+LEN}.\hypertarget{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1953}{}\doxysection{Considered Alternatives}\label{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1953}
An alternative would be to always store a zero byte after all key values, even if they are binary (might be done already). Then we can safely return {\ttfamily k-\/$>$data.\+c == NULL ? \char`\"{}\char`\"{} \+: k-\/$>$data.\+c}. It may contain incomplete data and the {\ttfamily MAX\+\_\+\+LEN} problem from above still applies, but there are no segfaults and you don\textquotesingle{}t get return values that have nothing to do with the actual data.\hypertarget{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1954}{}\doxysection{Decision}\label{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1954}

\begin{DoxyItemize}
\item {\ttfamily key == NULL} return 0, error code via second channel
\item {\ttfamily key-\/$>$value == NULL} return 0, error code via second channel
\item {\ttfamily key == $<$binary$>$} return 0, error code via second channel
\item everything else as is
\end{DoxyItemize}\hypertarget{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1955}{}\doxysection{Rationale}\label{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1955}

\begin{DoxyItemize}
\item 0 seems like the most intuitive value to return in case of an error, although this introduces the possibility of segfaults for users of the library. printf doesn\textquotesingle{}t cause segfaults anymore, which improves this problem a lot.
\item With the introduction of a second channel for reporting errors, users can check the error messages in case of segfaults -\/ which alleviates this issue. The first thing in case of an error should be checking the error message.
\end{DoxyItemize}\hypertarget{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1956}{}\doxysection{Implications}\label{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1956}
\hypertarget{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1957}{}\doxysection{Related Decisions}\label{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1957}
\hypertarget{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1958}{}\doxysection{Notes}\label{doc_decisions_1_problem_clear_key_string_return_value_md_autotoc_md1958}
