pussuw commented on code in PR #9030:
URL: https://github.com/apache/nuttx/pull/9030#discussion_r1169746610


##########
sched/addrenv/addrenv.c:
##########
@@ -237,62 +208,48 @@ int addrenv_switch(FAR struct tcb_s *tcb)
  *   Allocate an address environment for a new process.
  *
  * Input Parameters:
- *   tcb   - The tcb of the newly created task.
- *   ttype - The type of the task.
+ *   None
  *
  * Returned Value:
- *   This is a NuttX internal function so it follows the convention that
- *   0 (OK) is returned on success and a negated errno is returned on
- *   failure.
+ *   Pointer to the new address environment, or NULL if out of memory.
  *
  ****************************************************************************/
 
-int addrenv_allocate(FAR struct tcb_s *tcb, uint8_t ttype)
+FAR struct addrenv_s *addrenv_allocate(void)
 {
-  int ret = OK;
+  FAR struct addrenv_s *addrenv;
 
-  if ((ttype & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
+  addrenv = (FAR struct addrenv_s *)kmm_zalloc(sizeof(struct addrenv_s));
+  if (addrenv)
     {
-      tcb->addrenv_own = NULL;
-    }
-  else
-    {
-      tcb->addrenv_own = (FAR struct addrenv_s *)
-        kmm_zalloc(sizeof(struct addrenv_s));
-      if (tcb->addrenv_own == NULL)
-        {
-          ret = -ENOMEM;
-        }
+      /* Take reference so this won't get freed */
+
+      addrenv->refs = 1;
     }
 
-  return ret;
+  return addrenv;
 }
 
 /****************************************************************************
  * Name: addrenv_free
  *
  * Description:
- *   Free an address environment for a process.
+ *   Unconditionally free an address environment.

Review Comment:
   I solved this by removing the function entirely, I realized after your 
comment it is not needed anyway :)



-- 
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