Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/malloc.c

    rdd50aa19 r44e8541  
    3838#include <stdbool.h>
    3939#include <stddef.h>
    40 #include <stdio.h>
    4140#include <as.h>
    4241#include <align.h>
     
    726725 *
    727726 */
    728 static void *malloc_internal(size_t size, size_t align)
     727static void *malloc_internal(const size_t size, const size_t align)
    729728{
    730729        malloc_assert(first_heap_area != NULL);
    731730
    732         if (size == 0)
    733                 size = 1;
    734 
    735731        if (align == 0)
    736                 align = BASE_ALIGN;
     732                return NULL;
    737733
    738734        size_t falign = lcm(align, BASE_ALIGN);
     
    825821 *
    826822 */
    827 void *realloc(void *const addr, size_t size)
     823void *realloc(void *const addr, const size_t size)
    828824{
    829825        if (size == 0) {
    830                 fprintf(stderr, "realloc() called with size 0\n");
    831                 size = 1;
     826                free(addr);
     827                return NULL;
    832828        }
    833829
     
    934930}
    935931
    936 /** Reallocate memory for an array
    937  *
    938  * Same as realloc(ptr, nelem * elsize), except the multiplication is checked
    939  * for numerical overflow. Borrowed from POSIX 2024.
    940  *
    941  * @param ptr
    942  * @param nelem
    943  * @param elsize
    944  *
    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 
    955932/** Free a memory block
    956933 *
Note: See TracChangeset for help on using the changeset viewer.