Commit Graph

7 Commits

Author SHA1 Message Date
Alin Jerpelea 339457dda3 mm: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-09-13 08:49:05 +08:00
Petro Karashchenko 5a298e8685 mm: memory allocations return valid pointer when request 0 size
This change introduce 2 items:
1. If the size of the space requested is 0, the behavior is implementation-defined:
   either a null pointer shall be returned, or the behavior shall be as if the size
   were some non-zero value, except that the behavior is undefined if the returned
   pointer is used to access an object.

   Change the behavior to be similar to Linux and Android and allocates an object
   of a minimum size instead of returning null pointer.

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

2. The description of realloc() has been modified from previous versions of this
   standard to align with the ISO/IEC 9899:1999 standard. Previous versions explicitly
   permitted a call to realloc (p, 0) to free the space pointed to by p and return
   a null pointer. While this behavior could be interpreted as permitted by this
   version of the standard, the C language committee have indicated that this
   interpretation is incorrect. Applications should assume that if realloc() returns
   a null pointer, the space pointed to by p has not been freed. Since this could lead
   to double-frees, implementations should also set errno if a null pointer actually
   indicates a failure, and applications should only free the space if errno was changed.

   Do not free memory of zero-length reallocation is requested

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

Co-authored-by: fangxinyong <fangxinyong@xiaomi.com>
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-05-02 18:29:29 -06:00
Alin Jerpelea bcee9c391c mm: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can mograte the licenses
to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-09 01:21:53 -08:00
Gregory Nutt 70efabd0ad mm/mm_heap/mm_calloc.c: Verify that the number of elements times the size of an element will not overflow type size_t. This is required by the SEI CERT C coding style and resolves anonymous Bitbucket Issue #139 2019-01-07 16:13:48 -06:00
Gregory Nutt c4493528a1 Remove some empty file section section header comments 2016-02-17 18:57:35 -06:00
Gregory Nutt b33c2d9cef Move include/nuttx/mm.h to include/nuttx/mm/mm.h 2014-09-24 07:29:09 -06:00
Gregory Nutt 3464089542 Move core heap allocator logic from mm/. to mm/mm_heap/. 2014-09-22 10:53:50 -06:00