Changeset 3722 for branches


Ignore:
Timestamp:
Mar 17, 2011, 10:33:44 PM (14 years ago)
Author:
bird
Message:

0.6: Backported r3721: posix_memalign.c: Always set errno. References #223.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/src/lib/malloc/posix_memalign.c

    r2254 r3722  
    3131#include <stdlib.h>
    3232#include <stddef.h>
     33#include <errno.h>
    3334#include <umalloc.h>
    3435#include <emx/umalloc.h>
     
    5960     */
    6061    *memptr = NULL;                     /* touch it so we crash here. */
    61     /** @todo verify that alignment is a power of 2 */
     62    if (   (alignment & (alignment - 1)) != 0
     63        || alignment < sizeof(void *))
     64    {
     65        errno = EINVAL;
     66        LIBCLOG_ERROR_RETURN_INT(-1);
     67    }
    6268
    6369    /*
     
    6975    assert(Heap->magic == _UM_MAGIC_HEAP);
    7076    if (Heap->magic != _UM_MAGIC_HEAP)
     77    {
     78        errno = EDOOFUS;
    7179        LIBCLOG_ERROR_RETURN_INT(-1);
     80    }
    7281
    7382    /*
     
    8796    if (pv)
    8897        LIBCLOG_RETURN_INT(0);
     98    errno = ENOMEM;
    8999    LIBCLOG_ERROR_RETURN_INT(-1);
    90100}
Note: See TracChangeset for help on using the changeset viewer.