xiaoxiang781216 commented on code in PR #18883:
URL: https://github.com/apache/nuttx/pull/18883#discussion_r3252562172


##########
arch/sim/src/sim/posix/sim_macho_init.c:
##########
@@ -96,23 +99,28 @@ static void save_and_replace_init_funcs(int argc, const 
char *argv[],
   g_saved_envp = envp;
   g_saved_apple = apple;
 
-  g_saved_init_funcs = malloc(g_num_saved_init_funcs *
-                              sizeof(*g_saved_init_funcs));
+  g_saved_init_funcs = malloc((nfuncs - 1) * sizeof(*g_saved_init_funcs));
   allow_write(&mod_init_func_start, &mod_init_func_end);
-  int i = 0;
+  i = 0;
   for (fp = &mod_init_func_start; fp < &mod_init_func_end; fp++)
     {
       if (*fp == save_and_replace_init_funcs)
         {
-          assert(i == 0);

Review Comment:
   save_and_replace_init_funcs must be the first entry, so it can move all 
constructors to new array and call them after nuttx kernel finish the basic 
initialization.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to