Changeset 10730 for trunk/FACT++/src
- Timestamp:
- 05/17/11 20:18:33 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ByteOrder.h
r10703 r10730 87 87 void bitcpy(T *target, size_t ntarget, const S *source, size_t nsource, size_t ss=0, size_t ts=0) 88 88 { 89 const size_t targetsize = ss==0 ? sizeof(T) : std::min(ss, sizeof(T));90 const size_t sourcesize = ts==0 ? sizeof(S) : std::min(ts, sizeof(S));89 const size_t targetsize = ts==0 ? sizeof(T)*8 : std::min(ts, sizeof(T)*8); 90 const size_t sourcesize = ss==0 ? sizeof(S)*8 : std::min(ss, sizeof(S)*8); 91 91 92 92 const S *const ends = source + nsource; … … 106 106 *t |= (*s>>sourcepos)<<targetpos; 107 107 108 // If not all bits fitted into targetsize the number 109 // of copied bits is the number of bits which fitted 110 const int n = std::min(sourcesize-sourcepos, targetsize-targetpos); 108 // Calculate how many bits were siuccessfully copied 109 const int ncopy = std::min(sourcesize-sourcepos, targetsize-targetpos); 111 110 112 targetpos += n ;113 sourcepos += n ;111 targetpos += ncopy; 112 sourcepos += ncopy; 114 113 115 114 if (sourcepos>=sourcesize) 115 { 116 sourcepos %= sourcesize; 116 117 s++; 118 } 117 119 118 120 if (targetpos>=targetsize) 121 { 122 targetpos %= targetsize; 119 123 t++; 124 } 120 125 121 sourcepos %= sourcesize;122 targetpos %= targetsize;123 126 } 124 127 }
Note:
See TracChangeset
for help on using the changeset viewer.