Ignore:
Timestamp:
Feb 17, 2016, 4:12:02 PM (9 years ago)
Author:
meunier
Message:
  • Added function realloc
  • Started to put the bootloader on 2 Big Pages (warning: does not work yet)
  • Fixed errors in the rosenfeld application
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_libs/malloc.c

    r781 r791  
    305305}
    306306
     307
     308/////////////////////////////////////////////////
     309// Added by QM
     310// Warning, I can't have tested this function yet
     311/////////////////////////////////////////////////
     312void * realloc ( void * ptr, int size )
     313{
     314    if ( ptr == NULL )
     315    {
     316        return malloc( size );
     317    }
     318    if ( size == 0 )
     319    {
     320        free( ptr );
     321        return NULL;
     322    }
     323    unsigned int x;
     324    unsigned int y;
     325    giet_get_xy( ptr, &x, &y );
     326    unsigned int base = (unsigned int) ptr;
     327    int index = (base - heap[x][y].heap_base) / MIN_BLOCK_SIZE;
     328
     329    char * pchar = (char *) (heap[x][y].alloc_base + index);
     330    int old_size = 1 << ((int) *pchar);
     331
     332    void * new_ptr = malloc( size );
     333    int min_size = (size < old_size) ? size : old_size;
     334    memcpy( new_ptr, ptr, min_size );
     335    free( ptr );
     336    return new_ptr;
     337}
     338
     339
     340
    307341///////////////////////////////////////////
    308342void update_free_array( giet_heap_t* heap,
Note: See TracChangeset for help on using the changeset viewer.