doc: Specify that string memory must be freed
authorErica Bugden <ebugden@efficios.com>
Thu, 4 Jul 2024 19:26:16 +0000 (15:26 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 21 Oct 2024 18:56:30 +0000 (14:56 -0400)
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 <ebugden@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng/utils.cpp

index 7831ae65a4f695befc4a5448cafe435cf6220e3d..e57bd1b550b8119e3342db5334249bc33e1cf339 100644 (file)
@@ -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()
 {
This page took 0.026971 seconds and 4 git commands to generate.