Changeset 3721 for trunk


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

posix_memalign.c: Always set errno. References #223.

Location:
trunk/libc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/src/libc/malloc/posix_memalign.c

    r2254 r3721  
    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}
  • trunk/libc/tests/libc/bugs/223-posix-memalign.c

    r3719 r3721  
    88    static size_t const s_acbAlignments[] =
    99    {
    10         1,
    11         2,
    12         4,
     10        sizeof(void *),
    1311        16,
    1412        32,
Note: See TracChangeset for help on using the changeset viewer.