Changeset 167 for trunk/thune/array.c

Show
Ignore:
Timestamp:
06/04/06 04:58:45 (3 years ago)
Author:
krobillard
Message:

Fixed a couple cases where reading beyond end of buffer.
Optimized ur_arrayErase() when elemSize == 16 and WORDSIZE == 64.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/array.c

    r1 r167  
    131131    else if( elemSize == 16 ) 
    132132    { 
     133#if __WORDSIZE == 64 
     134        uint64_t* buf; 
     135        uint64_t* src; 
     136        uint64_t* end; 
     137 
     138        buf = ((uint64_t*) arr->ptr.i) + (index * 2); 
     139        src = buf + (count * 2); 
     140        end = ((uint64_t*) arr->ptr.i) + (arr->used * 2); 
     141 
     142        while( src != end ) 
     143        { 
     144            *buf++ = *src++; 
     145            *buf++ = *src++; 
     146        } 
     147#else 
    133148        uint32_t* buf; 
    134149        uint32_t* src; 
     
    146161            *buf++ = *src++; 
    147162        } 
     163#endif 
    148164    } 
    149165    else 
     
    151167        char* buf;  
    152168        buf = arr->ptr.c + (elemSize * index); 
    153         memMove( buf, buf + elemSize, elemSize * (arr->used - index) ); 
     169        memMove( buf, buf + (elemSize * count), 
     170                 elemSize * (arr->used - index - count) ); 
    154171    } 
    155172