cmdline: free on exit
authorZhihong Peng <zhihongx.peng@intel.com>
Mon, 18 Oct 2021 13:58:50 +0000 (21:58 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 22 Oct 2021 21:32:00 +0000 (23:32 +0200)
Malloc cl in the cmdline_stdin_new function, so release in the
cmdline_stdin_exit function is logical, so that cl will not be
released alone.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Zhihong Peng <zhihongx.peng@intel.com>
Reviewed-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
Tested-by: Zhihong Peng <zhihongx.peng@intel.com>
app/test/test.c
app/test/test_cmdline_lib.c
doc/guides/rel_notes/release_21_11.rst
lib/cmdline/cmdline_socket.c

index 173d202..5194131 100644 (file)
@@ -233,7 +233,6 @@ main(int argc, char **argv)
 
                cmdline_interact(cl);
                cmdline_stdin_exit(cl);
-               cmdline_free(cl);
        }
 #endif
        ret = 0;
index 054ebf5..f238094 100644 (file)
@@ -180,7 +180,6 @@ test_cmdline_socket_fns(void)
        /* void functions */
        cmdline_stdin_exit(NULL);
 
-       cmdline_free(cl);
        return 0;
 error:
        printf("Error: function accepted null parameter!\n");
index 9b1843e..450bcbb 100644 (file)
@@ -325,6 +325,9 @@ API Changes
   removed. Its usages have been replaced by a new function
   ``rte_kvargs_get_with_value()``.
 
+* cmdline: ``cmdline_stdin_exit()`` now frees the ``cmdline`` structure.
+  Calls to ``cmdline_free()`` after it need to be deleted from applications.
+
 * cmdline: Made ``cmdline`` structure definition hidden on Linux and FreeBSD.
 
 * cmdline: Made ``rdline`` structure definition hidden. Functions are added
index 998e8ad..ebd5343 100644 (file)
@@ -53,4 +53,5 @@ cmdline_stdin_exit(struct cmdline *cl)
                return;
 
        terminal_restore(cl);
+       cmdline_free(cl);
 }