[Bug 1510] New: Wrong memory allocation check in example

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Wed May 5 20:39:22 UTC 2010


https://www.rtems.org/bugzilla/show_bug.cgi?id=1510

           Summary: Wrong memory allocation check in example
           Product: RTEMS
           Version: unknown
          Platform: All
               URL: http://rtems.com/onlinedocs/doc-current/share/rtems/ht
                    ml/c_user/c_user00513.html
        OS/Version: RTEMS
            Status: NEW
          Severity: trivial
          Priority: P3
         Component: doc
        AssignedTo: joel.sherrill at oarcorp.com
        ReportedBy: alin.codejunkie at gmail.com
                CC: chrisj at rtems.org


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

-- 
Configure bugmail: https://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the bugs mailing list