[RTEMS Project] #1510: Wrong memory allocation check in example

RTEMS trac trac at rtems.org
Sun Nov 23 19:13:52 UTC 2014


#1510: Wrong memory allocation check in example
-----------------------------+----------------------------
 Reporter:  alin.codejunkie  |       Owner:  joel.sherrill
     Type:  defect           |      Status:  closed
 Priority:  normal           |   Milestone:  4.11
Component:  doc              |     Version:  4.10
 Severity:  trivial          |  Resolution:  fixed
 Keywords:                   |
-----------------------------+----------------------------
Changes (by joel.sherrill):

 * version:  unknown => 4.10
 * milestone:  4.10 => 4.11


Old description:

> The memory allocation check in this example is incorrect
> http://rtems.com/onlinedocs/doc-
> current/share/rtems/html/c_user/c_user00513.html
>
>   foo* bar = malloc (sizeof (foo));
>   if (!foo)
>      return -1;
>
> You should have:
>
>   foo* bar = malloc (sizeof (foo));
>   if (!bar)
>      return -1;
>
> Since bar is the pointer to the allocated memory

New description:

 The memory allocation check in this example is incorrect
 http://rtems.com/onlinedocs/doc-
 current/share/rtems/html/c_user/c_user00513.html

   foo* bar = malloc (sizeof (foo));
   if (!foo)
      return -1;

 You should have:

   foo* bar = malloc (sizeof (foo));
   if (!bar)
      return -1;

 Since bar is the pointer to the allocated memory

--

--
Ticket URL: <http://devel.rtems.org/ticket/1510#comment:2>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list