nuttx/mm/mm_heap
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
..
Make.defs Replace nxsem API when used as a lock with nxmutex API 2022-10-17 15:59:46 +09:00
mm_addfreechunk.c mm: support custom the mm alignment and default to be 8 2023-03-06 11:10:36 +08:00
mm_brkaddr.c mm: Remove mm_heap_impl_s struct 2021-07-07 04:25:15 -07:00
mm_calloc.c mm: memory allocations return valid pointer when request 0 size 2023-05-02 18:29:29 -06:00
mm_checkcorruption.c mm: support custom the mm alignment and default to be 8 2023-03-06 11:10:36 +08:00
mm_extend.c mm: move preceding to previous free node to reduce the overhead 2023-02-01 11:14:02 +08:00
mm_foreach.c mm: move preceding to previous free node to reduce the overhead 2023-02-01 11:14:02 +08:00
mm_free.c mm: move preceding to previous free node to reduce the overhead 2023-02-01 11:14:02 +08:00
mm_heapmember.c mm: Remove mm_heap_impl_s struct 2021-07-07 04:25:15 -07:00
mm_initialize.c memepool:fix memory consumption double counting issue 2023-04-23 23:28:32 +08:00
mm_lock.c sched/getpid: replace syscall getpid/tid/ppid() to kernel version 2023-02-02 10:33:01 +08:00
mm_mallinfo.c mm:change special pid to macro 2023-04-23 23:28:32 +08:00
mm_malloc_size.c mm: move preceding to previous free node to reduce the overhead 2023-02-01 11:14:02 +08:00
mm_malloc.c mm: memory allocations return valid pointer when request 0 size 2023-05-02 18:29:29 -06:00
mm_memalign.c mm: support custom the mm alignment and default to be 8 2023-03-06 11:10:36 +08:00
mm_memdump.c mm:change special pid to macro 2023-04-23 23:28:32 +08:00
mm_realloc.c mm: memory allocations return valid pointer when request 0 size 2023-05-02 18:29:29 -06:00
mm_shrinkchunk.c mm: support custom the mm alignment and default to be 8 2023-03-06 11:10:36 +08:00
mm_size2ndx.c mm: support custom the mm alignment and default to be 8 2023-03-06 11:10:36 +08:00
mm_zalloc.c
mm.h mm_heap: double malloced memory default alignment (4 -> 8, 8 -> 16) 2023-03-06 11:27:43 +01:00