Changeset 686


Ignore:
Timestamp:
Aug 3, 2015, 7:07:03 PM (9 years ago)
Author:
guerin
Message:

remove almalloc implementation

It is in fact useless because malloc already returns aligned addresses.
Should have read the doc first ;)

Location:
soft/giet_vm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/raycast/disp.c

    r685 r686  
    210210
    211211    // Allocate framebuffer
    212     buf[0] = almalloc(64, FBUF_X_SIZE * FBUF_Y_SIZE);
    213     buf[1] = almalloc(64, FBUF_X_SIZE * FBUF_Y_SIZE);
    214     sts[0] = almalloc(64, 64);
    215     sts[1] = almalloc(64, 64);
     212    buf[0] = malloc(FBUF_X_SIZE * FBUF_Y_SIZE);
     213    buf[1] = malloc(FBUF_X_SIZE * FBUF_Y_SIZE);
     214    sts[0] = malloc(64);
     215    sts[1] = malloc(64);
    216216
    217217    // Initialize framebuffer
  • soft/giet_vm/giet_libs/malloc.c

    r680 r686  
    431431} // end free()
    432432
    433 //////////////////////
    434 // reference: http://stackoverflow.com/a/6563989/4244300
    435 void * almalloc( unsigned int align, unsigned int size )
    436 {
    437     unsigned int total_size;
    438     void* ptr;
    439 
    440     // check if align is a power of two
    441     if ( !align || (align & (align - 1)) )
    442         return NULL;
    443 
    444     // reserve memory for data + offset + book-keeping
    445     total_size = size + align + sizeof(void*);
    446     ptr = malloc( total_size );
    447 
    448     if ( ptr )
    449     {
    450         void* start = ptr;
    451         void** book;
    452 
    453         // find aligned ptr
    454         ptr += sizeof(void*);
    455         ptr += align - ((unsigned int)ptr % align);
    456 
    457         // keep original ptr just before the actual data
    458         book = ptr - sizeof(void*);
    459         *book = start;
    460     }
    461 
    462     return ptr;
    463 }
    464 
    465 //////////////////////
    466 void alfree( void* ptr )
    467 {
    468     if ( ptr )
    469     {
    470         void** book = ptr - sizeof(void*);
    471         free(*book);
    472     }
    473 }
    474 
    475433// Local Variables:
    476434// tab-width: 4
  • soft/giet_vm/giet_libs/malloc.h

    r678 r686  
    101101extern void free(void * ptr);
    102102
    103 extern void* almalloc (unsigned int align, unsigned int size );
    104 
    105 extern void alfree(void * ptr);
    106 
    107103#endif
    108104
Note: See TracChangeset for help on using the changeset viewer.