From c38ec0db1dc0412b7efeccca9aaf45075a24d456 Mon Sep 17 00:00:00 2001 From: Erica Bugden Date: Thu, 4 Jul 2024 15:26:16 -0400 Subject: [PATCH] doc: Specify that string memory must be freed MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/bin/lttng/utils.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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() { -- 2.34.1