pkarashchenko commented on code in PR #1706:
URL: https://github.com/apache/nuttx-apps/pull/1706#discussion_r1158296454


##########
nshlib/nsh_parse.c:
##########
@@ -59,11 +59,29 @@
 #  define HAVE_MEMLIST 1
 #endif
 
+/* If CONFIG_NSH_ALIAS is enabled, the alias strings might need dynamic
+ * memory, in case the alias has arguments and is set like:
+ *
+ * $ alias ls='ls -l'
+ *
+ * In this case the command verb and the arguments need to be separated, much
+ * like the argument separation is done with environment variable expansion.
+ *
+ * This needs a new working buffer in order to keep the original alias string
+ * intact.
+ */
+
+#ifdef CONFIG_NSH_ALIAS
+#  define ALIAS_ALLOCS           2
+#else
+#  define ALIAS_ALLOCS           0
+#endif
+
 #if defined(HAVE_MEMLIST) && !defined(CONFIG_NSH_MAXALLOCS)
 #  ifdef CONFIG_NSH_ARGCAT
-#    define CONFIG_NSH_MAXALLOCS (2*CONFIG_NSH_MAXARGUMENTS)
+#    define CONFIG_NSH_MAXALLOCS ((2*CONFIG_NSH_MAXARGUMENTS) + ALIAS_ALLOCS)

Review Comment:
   ```suggestion
   #    define CONFIG_NSH_MAXALLOCS ((2 * CONFIG_NSH_MAXARGUMENTS) + 
ALIAS_ALLOCS)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to