Changeset a46da63 in mainline for libc/generic/as.c


Ignore:
Timestamp:
2006-06-16T20:50:51Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
153a209
Parents:
b34fab6
Message:

big code cleanup, compile with -Wall -Werror to enforce better coding
there is currently one warning that requires attention, please review

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libc/generic/as.c

    rb34fab6 ra46da63  
    2727 */
    2828
    29  /** @addtogroup libc
     29/** @addtogroup libc
    3030 * @{
    3131 */
     
    7676
    7777static size_t heapsize = 0;
    78 static size_t maxheapsize = (size_t)(-1);
     78static size_t maxheapsize = (size_t) (-1);
    7979
    8080static void * last_allocated = 0;
     
    9393        int rc;
    9494        void *res;
     95       
    9596        /* Check for invalid values */
    9697        if (incr < 0 && -incr > heapsize)
    9798                return NULL;
     99       
    98100        /* Check for too large value */
    99101        if (incr > 0 && incr+heapsize < heapsize)
    100102                return NULL;
     103       
    101104        /* Check for too small values */
    102105        if (incr < 0 && incr+heapsize > heapsize)
    103106                return NULL;
     107       
    104108        /* Check for user limit */
    105         if ((maxheapsize!=(size_t)(-1)) && (heapsize + incr)>maxheapsize) return NULL;
    106 
    107         rc = as_area_resize(&_heap, heapsize + incr,0);
     109        if ((maxheapsize != (size_t) (-1)) && (heapsize + incr) > maxheapsize)
     110                return NULL;
     111       
     112        rc = as_area_resize(&_heap, heapsize + incr, 0);
    108113        if (rc != 0)
    109114                return NULL;
    110115       
    111116        /* Compute start of new area */
    112         res = (void *)&_heap + heapsize;
     117        res = (void *) &_heap + heapsize;
    113118
    114119        heapsize += incr;
     
    120125void *set_maxheapsize(size_t mhs)
    121126{
    122         maxheapsize=mhs;
     127        maxheapsize = mhs;
    123128        /* Return pointer to area not managed by sbrk */
    124         return (void *)&_heap + maxheapsize;
     129        return ((void *) &_heap + maxheapsize);
    125130
    126131}
     
    137142        /* Set heapsize to some meaningful value */
    138143        if (maxheapsize == -1)
    139                 set_maxheapsize(ALIGN_UP(USER_ADDRESS_SPACE_SIZE_ARCH>>1,PAGE_SIZE));
     144                set_maxheapsize(ALIGN_UP(USER_ADDRESS_SPACE_SIZE_ARCH >> 1, PAGE_SIZE));
     145       
    140146        if (!last_allocated)
    141                 last_allocated = ALIGN_UP((void *)&_heap + maxheapsize, PAGE_SIZE);
     147                last_allocated = (void *) ALIGN_UP((void *) &_heap + maxheapsize, PAGE_SIZE);
    142148       
    143149        sz = ALIGN_UP(sz, PAGE_SIZE);
     
    148154}
    149155
    150 
    151  /** @}
     156/** @}
    152157 */
    153  
    154  
Note: See TracChangeset for help on using the changeset viewer.