Changeset 9fd69c1 in rtems-libbsd


Ignore:
Timestamp:
Oct 30, 2013, 1:41:44 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, afaeccc05a556f6aa25ba044a7e49d6aa634a59e, freebsd-9.3, master
Children:
a400e1d
Parents:
f0d189c
git-author:
Sebastian Huber <sebastian.huber@…> (10/30/13 13:41:44)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/31/13 12:18:54)
Message:

MALLOC(9): Return valid pointer for malloc(0), etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtemsbsd/rtems/rtems-bsd-malloc.c

    rf0d189c r9fd69c1  
    7575_bsd_malloc(unsigned long size, struct malloc_type *mtp, int flags)
    7676{
    77         void *p = malloc(size);
     77        void *p = malloc(size > 0 ? size : 1);
    7878
    7979        if ((flags & M_ZERO) != 0 && p != NULL) {
     
    8989  struct malloc_type *type, int flags)
    9090{
    91         void *p = realloc(addr, size);
     91        void *p = realloc(addr, size > 0 ? size : 1);
    9292
    9393        if ((flags & M_ZERO) != 0 && p != NULL) {
     
    103103  struct malloc_type *type, int flags)
    104104{
    105         void *p = realloc(addr, size);
     105        void *p = realloc(addr, size > 0 ? size : 1);
    106106
    107107        if (p == NULL) {
Note: See TracChangeset for help on using the changeset viewer.