Changes in uspace/lib/c/generic/malloc.c [dd50aa19:44e8541] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/malloc.c
rdd50aa19 r44e8541 38 38 #include <stdbool.h> 39 39 #include <stddef.h> 40 #include <stdio.h>41 40 #include <as.h> 42 41 #include <align.h> … … 726 725 * 727 726 */ 728 static void *malloc_internal( size_t size,size_t align)727 static void *malloc_internal(const size_t size, const size_t align) 729 728 { 730 729 malloc_assert(first_heap_area != NULL); 731 730 732 if (size == 0)733 size = 1;734 735 731 if (align == 0) 736 align = BASE_ALIGN;732 return NULL; 737 733 738 734 size_t falign = lcm(align, BASE_ALIGN); … … 825 821 * 826 822 */ 827 void *realloc(void *const addr, size_t size)823 void *realloc(void *const addr, const size_t size) 828 824 { 829 825 if (size == 0) { 830 f printf(stderr, "realloc() called with size 0\n");831 size = 1;826 free(addr); 827 return NULL; 832 828 } 833 829 … … 934 930 } 935 931 936 /** Reallocate memory for an array937 *938 * Same as realloc(ptr, nelem * elsize), except the multiplication is checked939 * for numerical overflow. Borrowed from POSIX 2024.940 *941 * @param ptr942 * @param nelem943 * @param elsize944 *945 * @return Reallocated memory or NULL.946 */947 void *reallocarray(void *ptr, size_t nelem, size_t elsize)948 {949 if (nelem > SIZE_MAX / elsize)950 return NULL;951 952 return realloc(ptr, nelem * elsize);953 }954 955 932 /** Free a memory block 956 933 *
Note:
See TracChangeset
for help on using the changeset viewer.