Changeset 3720 for branches/libc-0.6


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

0.6: Backported r3719: posix_memalign: Fixed problem with large alignment values. Fixes #223.

File:
1 edited

Legend:

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

    r1457 r3720  
    246246
    247247/* Attempt to expand the heap to enable allocation of a lump of SIZE
    248    bytes.  Return true iff successful. */
    249 
    250 static int _um_heap_expand (Heap_t h, size_t size)
     248   bytes suitable for an ALIGN aligned allocation. 
     249   Return true iff successful. */
     250
     251static int _um_heap_expand (Heap_t h, size_t size, size_t align)
    251252{
    252253  size_t rsize, add_size;
     
    259260    return 0;
    260261
    261   rsize = _UM_ROUND_LUMP (size);
     262  if (align < _UM_PAGE_SIZE / 2)
     263    rsize = _UM_ROUND_LUMP (size);
     264  else
     265    rsize = _UM_ROUND_LUMP (size + align + align / 2);
    262266  if (rsize >= _UM_MAX_SIZE)
    263267    return 0;
     
    292296  if (block != NULL)
    293297    return block;
    294   if (!_um_heap_expand (h, size))
     298  if (!_um_heap_expand (h, size, align))
    295299    return NULL;
    296300
Note: See TracChangeset for help on using the changeset viewer.