diff options
Diffstat (limited to 'src/nidsstream.cpp')
-rw-r--r-- | src/nidsstream.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/nidsstream.cpp b/src/nidsstream.cpp index fff73f6..31e1293 100644 --- a/src/nidsstream.cpp +++ b/src/nidsstream.cpp | |||
@@ -55,7 +55,7 @@ size_t Bu::NidsStream::read( void *pBuf, size_t nBytes ) | |||
55 | if( iRead > pCurBlock->uBytesUsed-(uPos%uBlockSize) ) | 55 | if( iRead > pCurBlock->uBytesUsed-(uPos%uBlockSize) ) |
56 | iRead = pCurBlock->uBytesUsed-(uPos%uBlockSize); | 56 | iRead = pCurBlock->uBytesUsed-(uPos%uBlockSize); |
57 | memcpy( pBuf, pCurBlock->pData+(uPos%uBlockSize), iRead ); | 57 | memcpy( pBuf, pCurBlock->pData+(uPos%uBlockSize), iRead ); |
58 | //printf("buffill: %ub, %u-%u/%u -> %d-%d/%d (a:%u)", | 58 | //printf("read buffill: %ub, %u-%u/%u -> %d-%d/%d (a:%u)", |
59 | // iRead, uPos, uPos+iRead-1, uSize, 0, iRead-1, nBytes, uCurBlock ); | 59 | // iRead, uPos, uPos+iRead-1, uSize, 0, iRead-1, nBytes, uCurBlock ); |
60 | uPos += iRead; | 60 | uPos += iRead; |
61 | //printf(" -- %u\n", uPos%uBlockSize ); | 61 | //printf(" -- %u\n", uPos%uBlockSize ); |
@@ -80,7 +80,7 @@ size_t Bu::NidsStream::read( void *pBuf, size_t nBytes ) | |||
80 | iRead = pCurBlock->uBytesUsed-(uPos%uBlockSize); | 80 | iRead = pCurBlock->uBytesUsed-(uPos%uBlockSize); |
81 | memcpy( ((char *)pBuf)+nTotal, | 81 | memcpy( ((char *)pBuf)+nTotal, |
82 | pCurBlock->pData+(uPos%uBlockSize), iRead ); | 82 | pCurBlock->pData+(uPos%uBlockSize), iRead ); |
83 | //printf("buffill: %ub, %u-%u/%u -> %d-%d/%d (b:%u)\n", | 83 | //printf(" read buffill: %ub, %u-%u/%u -> %d-%d/%d (b:%u)\n", |
84 | // iRead, uPos, uPos+iRead-1, uSize, | 84 | // iRead, uPos, uPos+iRead-1, uSize, |
85 | // nTotal, nTotal+nBytes-1, nBytes, uCurBlock ); | 85 | // nTotal, nTotal+nBytes-1, nBytes, uCurBlock ); |
86 | uPos += iRead; | 86 | uPos += iRead; |
@@ -111,6 +111,10 @@ size_t Bu::NidsStream::write( const void *pBuf, size_t nBytes ) | |||
111 | { | 111 | { |
112 | //printf("wa: %u:%u:%u:%u -> ", uPos, uPos%uBlockSize, uSize, pCurBlock->uBytesUsed ); | 112 | //printf("wa: %u:%u:%u:%u -> ", uPos, uPos%uBlockSize, uSize, pCurBlock->uBytesUsed ); |
113 | memcpy( pCurBlock->pData+(uPos%uBlockSize), pBuf, nBytes ); | 113 | memcpy( pCurBlock->pData+(uPos%uBlockSize), pBuf, nBytes ); |
114 | //printf("write buffill: %ub, %u-%u/%u -> %d-%d/%d (a:%u:%u)\n", | ||
115 | // nBytes, 0, nBytes-1, nBytes, | ||
116 | // uPos, uPos+nBytes-1, uSize, uCurBlock, | ||
117 | // pCurBlock->uBytesUsed ); | ||
114 | if( (uPos%uBlockSize)+nBytes > pCurBlock->uBytesUsed ) | 118 | if( (uPos%uBlockSize)+nBytes > pCurBlock->uBytesUsed ) |
115 | pCurBlock->uBytesUsed = (uPos%uBlockSize)+nBytes; | 119 | pCurBlock->uBytesUsed = (uPos%uBlockSize)+nBytes; |
116 | rNids.setBlock( uCurBlock, pCurBlock ); | 120 | rNids.setBlock( uCurBlock, pCurBlock ); |
@@ -132,6 +136,9 @@ size_t Bu::NidsStream::write( const void *pBuf, size_t nBytes ) | |||
132 | uNow = nBytes; | 136 | uNow = nBytes; |
133 | memcpy( pCurBlock->pData+(uPos%uBlockSize), | 137 | memcpy( pCurBlock->pData+(uPos%uBlockSize), |
134 | &((char *)pBuf)[nTotal], uNow ); | 138 | &((char *)pBuf)[nTotal], uNow ); |
139 | //printf("write buffill: %ub, %u-%u/%u -> %d-%d/%d (b:%u:%u)\n", | ||
140 | // uNow, nTotal, nTotal+uNow-1, nBytes, | ||
141 | // uPos, uPos+uNow-1, uSize, uCurBlock, pCurBlock->uBytesUsed ); | ||
135 | if( (uPos%uBlockSize)+uNow > pCurBlock->uBytesUsed ) | 142 | if( (uPos%uBlockSize)+uNow > pCurBlock->uBytesUsed ) |
136 | pCurBlock->uBytesUsed = (uPos%uBlockSize)+uNow; | 143 | pCurBlock->uBytesUsed = (uPos%uBlockSize)+uNow; |
137 | rNids.setBlock( uCurBlock, pCurBlock ); | 144 | rNids.setBlock( uCurBlock, pCurBlock ); |
@@ -142,7 +149,8 @@ size_t Bu::NidsStream::write( const void *pBuf, size_t nBytes ) | |||
142 | nBytes -= uNow; | 149 | nBytes -= uNow; |
143 | //printf("wb: block %u = %ub (%ub total)\n", | 150 | //printf("wb: block %u = %ub (%ub total)\n", |
144 | // uCurBlock, pCurBlock->uBytesUsed, uSize ); | 151 | // uCurBlock, pCurBlock->uBytesUsed, uSize ); |
145 | if( pCurBlock->uBytesUsed == uBlockSize ) | 152 | //if( pCurBlock->uBytesUsed == uBlockSize ) |
153 | if( uPos%uBlockSize == 0 ) | ||
146 | uCurBlock = rNids.getNextBlock( uCurBlock, pCurBlock ); | 154 | uCurBlock = rNids.getNextBlock( uCurBlock, pCurBlock ); |
147 | if( nBytes == 0 ) | 155 | if( nBytes == 0 ) |
148 | return nTotal; | 156 | return nTotal; |