From: Erica Bugden Date: Thu, 4 Jul 2024 19:26:16 +0000 (-0400) Subject: doc: Specify that string memory must be freed X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c38ec0db1dc0412b7efeccca9aaf45075a24d456;p=lttng-tools.git doc: Specify that string memory must be freed Specify that the caller of `get_session_name()` must explicitly free the memory associated with the returned string. Historically this software was written in C. C programmers have the reflex to assume they are responsible for freeing memory. However, now that this project is mixed C/C++ and is transitioning towards C++ the assumption that developers will automatically know to free memory (according to C programming conventions) does not hold as well. For this reason, clarify that memory must be explicitly freed by the function caller. There are other C functions in this software that return variables that must explicitly be freed by the caller. However, these changes have not been applied consistently to all these cases. The assumption is that this individual clarification still reduces confusion even if not applied consistently. Change-Id: I72d3568b5c1a7d8b7ff9b3d241bca1c5c55e47c1 Signed-off-by: Erica Bugden Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng/utils.cpp b/src/bin/lttng/utils.cpp index 7831ae65a..e57bd1b55 100644 --- a/src/bin/lttng/utils.cpp +++ b/src/bin/lttng/utils.cpp @@ -66,8 +66,11 @@ error: /* * get_session_name * - * Return allocated string with the session name found in the config - * directory. + * Return allocated string with the implicit session name (found in + * the config directory). + * + * The caller must explicitly free the memory associated with the + * returned string. */ char *get_session_name() {