Hello,

while working on the specification of some memory allocation directives I noticed that zero size allocations have no consistent behaviour in RTEMS. For example malloc( 0 ) returns NULL and posix_memalign(&p, align, 0) returns in p a unique pointer (or NULL if no memory is available). In POSIX zero size memory allocations are implementation-defined behaviour. The implementation has two options:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/malloc.html

https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_memalign.html

See also:

http://devel.rtems.org/ticket/4390

Linux returns a unique pointer for zero size memory allocations. I tend to use this approach as well and would like to remove the


  /*
   * Validate the parameters
   */
  if ( !size )
    return (void *) 0;

in the RTEMS malloc().

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to